@@ -64,21 +64,23 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
6464 self -> write_ram_command = write_ram_command ;
6565 self -> brightness_command = brightness_command ;
6666 self -> auto_brightness = auto_brightness ;
67+ self -> auto_refresh = auto_refresh ;
68+ self -> first_manual_refresh = !auto_refresh ;
6769 self -> data_as_commands = data_as_commands ;
6870
6971 self -> native_frames_per_second = native_frames_per_second ;
7072 self -> native_frame_time = 1000 / native_frames_per_second ;
7173
7274 uint32_t i = 0 ;
73- while (!displayio_display_core_begin_transaction (& self -> core )) {
74- RUN_BACKGROUND_TASKS ;
75- }
7675 while (i < init_sequence_len ) {
7776 uint8_t * cmd = init_sequence + i ;
7877 uint8_t data_size = * (cmd + 1 );
7978 bool delay = (data_size & DELAY ) != 0 ;
8079 data_size &= ~DELAY ;
8180 uint8_t * data = cmd + 2 ;
81+ while (!displayio_display_core_begin_transaction (& self -> core )) {
82+ RUN_BACKGROUND_TASKS ;
83+ }
8284 if (self -> data_as_commands ) {
8385 uint8_t full_command [data_size + 1 ];
8486 full_command [0 ] = cmd [0 ];
@@ -88,6 +90,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
8890 self -> core .send (self -> core .bus , true, true, cmd , 1 );
8991 self -> core .send (self -> core .bus , false, false, data , data_size );
9092 }
93+ self -> core .end_transaction (self -> core .bus );
9194 uint16_t delay_length_ms = 10 ;
9295 if (delay ) {
9396 data_size ++ ;
@@ -99,7 +102,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
99102 common_hal_time_delay_ms (delay_length_ms );
100103 i += 2 + data_size ;
101104 }
102- self -> core .end_transaction (self -> core .bus );
103105
104106 supervisor_start_terminal (width , height );
105107
@@ -192,9 +194,10 @@ STATIC const displayio_area_t* _get_refresh_areas(displayio_display_obj_t *self)
192194 if (self -> core .full_refresh ) {
193195 self -> core .area .next = NULL ;
194196 return & self -> core .area ;
195- } else {
197+ } else if ( self -> core . current_group != NULL ) {
196198 return displayio_group_get_refresh_areas (self -> core .current_group , NULL );
197199 }
200+ return NULL ;
198201}
199202
200203STATIC void _send_pixels (displayio_display_obj_t * self , uint8_t * pixels , uint32_t length ) {
@@ -242,7 +245,7 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t*
242245 // Allocated and shared as a uint32_t array so the compiler knows the
243246 // alignment everywhere.
244247 uint32_t buffer [buffer_size ];
245- volatile uint32_t mask_length = (pixels_per_buffer / 32 ) + 1 ;
248+ uint32_t mask_length = (pixels_per_buffer / 32 ) + 1 ;
246249 uint32_t mask [mask_length ];
247250 uint16_t remaining_rows = displayio_area_height (& clipped );
248251
@@ -311,7 +314,7 @@ uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self
311314}
312315
313316void common_hal_displayio_display_refresh (displayio_display_obj_t * self , uint32_t target_frame_time , uint32_t maximum_frame_time ) {
314- if (!self -> auto_refresh ) {
317+ if (!self -> auto_refresh && ! self -> first_manual_refresh ) {
315318 uint64_t current_time = ticks_ms ;
316319 uint32_t current_frame_time = current_time - self -> core .last_refresh ;
317320 // Test to see if the real frame time is below our minimum.
@@ -332,6 +335,7 @@ void common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_
332335 #endif
333336 }
334337 }
338+ self -> first_manual_refresh = false;
335339 _refresh_display (self );
336340}
337341
@@ -341,6 +345,7 @@ bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t* self
341345
342346void common_hal_displayio_display_set_auto_refresh (displayio_display_obj_t * self ,
343347 bool auto_refresh ) {
348+ self -> first_manual_refresh = !auto_refresh ;
344349 self -> auto_refresh = auto_refresh ;
345350}
346351
@@ -376,6 +381,12 @@ void release_display(displayio_display_obj_t* self) {
376381 }
377382}
378383
384+ void reset_display (displayio_display_obj_t * self ) {
385+ self -> auto_refresh = true;
386+ self -> auto_brightness = true;
387+ common_hal_displayio_display_show (self , NULL );
388+ }
389+
379390void displayio_display_collect_ptrs (displayio_display_obj_t * self ) {
380391 displayio_display_core_collect_ptrs (& self -> core );
381392}
0 commit comments