@@ -44,7 +44,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
4444 mp_obj_t bus , uint16_t width , uint16_t height , int16_t colstart , int16_t rowstart , uint16_t rotation ,
4545 uint16_t color_depth , uint8_t set_column_command , uint8_t set_row_command ,
4646 uint8_t write_ram_command , uint8_t set_vertical_scroll , uint8_t * init_sequence , uint16_t init_sequence_len ,
47- const mcu_pin_obj_t * backlight_pin , bool single_byte_bounds ) {
47+ const mcu_pin_obj_t * backlight_pin , bool single_byte_bounds , bool data_as_commands ) {
4848 self -> color_depth = color_depth ;
4949 self -> set_column_command = set_column_command ;
5050 self -> set_row_command = set_row_command ;
@@ -54,6 +54,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
5454 self -> colstart = colstart ;
5555 self -> rowstart = rowstart ;
5656 self -> auto_brightness = false;
57+ self -> data_as_commands = data_as_commands ;
5758 self -> single_byte_bounds = single_byte_bounds ;
5859
5960 if (MP_OBJ_IS_TYPE (bus , & displayio_parallelbus_type )) {
@@ -82,7 +83,13 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
8283 data_size &= ~DELAY ;
8384 uint8_t * data = cmd + 2 ;
8485 self -> send (self -> bus , true, cmd , 1 );
85- self -> send (self -> bus , false, data , data_size );
86+ if (self -> data_as_commands ) {
87+ for (uint32_t j = 0 ; j < data_size ; j ++ ) {
88+ self -> send (self -> bus , true, data + j , 1 );
89+ }
90+ } else {
91+ self -> send (self -> bus , false, data , data_size );
92+ }
8693 uint16_t delay_length_ms = 10 ;
8794 if (delay ) {
8895 data_size ++ ;
@@ -214,30 +221,33 @@ void displayio_display_end_transaction(displayio_display_obj_t* self) {
214221void displayio_display_set_region_to_update (displayio_display_obj_t * self , uint16_t x0 , uint16_t y0 , uint16_t x1 , uint16_t y1 ) {
215222
216223 self -> send (self -> bus , true, & self -> set_column_command , 1 );
224+ bool isCommand = self -> data_as_commands ;
217225 if (self -> single_byte_bounds ) {
218226 uint8_t data [2 ];
219227 data [0 ] = x0 + self -> colstart ;
220228 data [1 ] = x1 - 1 + self -> colstart ;
221- self -> send (self -> bus , false , (uint8_t * ) data , 2 );
229+ self -> send (self -> bus , isCommand , (uint8_t * ) data , 2 );
222230 } else {
223231 uint16_t data [2 ];
224232 data [0 ] = __builtin_bswap16 (x0 + self -> colstart );
225233 data [1 ] = __builtin_bswap16 (x1 - 1 + self -> colstart );
226- self -> send (self -> bus , false , (uint8_t * ) data , 4 );
234+ self -> send (self -> bus , isCommand , (uint8_t * ) data , 4 );
227235 }
228236 self -> send (self -> bus , true, & self -> set_row_command , 1 );
229237 if (self -> single_byte_bounds ) {
230238 uint8_t data [2 ];
231239 data [0 ] = y0 + self -> rowstart ;
232240 data [1 ] = y1 - 1 + self -> rowstart ;
233- self -> send (self -> bus , false , (uint8_t * ) data , 2 );
241+ self -> send (self -> bus , isCommand , (uint8_t * ) data , 2 );
234242 } else {
235243 uint16_t data [2 ];
236244 data [0 ] = __builtin_bswap16 (y0 + self -> rowstart );
237245 data [1 ] = __builtin_bswap16 (y1 - 1 + self -> rowstart );
238- self -> send (self -> bus , false, (uint8_t * ) data , 4 );
246+ self -> send (self -> bus , isCommand , (uint8_t * ) data , 4 );
247+ }
248+ if (!self -> data_as_commands ) {
249+ self -> send (self -> bus , true, & self -> write_ram_command , 1 );
239250 }
240- self -> send (self -> bus , true, & self -> write_ram_command , 1 );
241251}
242252
243253bool displayio_display_frame_queued (displayio_display_obj_t * self ) {
0 commit comments