@@ -170,6 +170,9 @@ void displayio_epaperdisplay_start_refresh(displayio_epaperdisplay_obj_t* self)
170170}
171171
172172uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh (displayio_epaperdisplay_obj_t * self ) {
173+ if (self -> core .last_refresh == 0 ) {
174+ return 0 ;
175+ }
173176 // Refresh at seconds per frame rate.
174177 uint32_t elapsed_time = ticks_ms - self -> core .last_refresh ;
175178 if (elapsed_time > self -> milliseconds_per_frame ) {
@@ -343,6 +346,13 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) {
343346}
344347
345348void release_epaperdisplay (displayio_epaperdisplay_obj_t * self ) {
349+ if (self -> refreshing ) {
350+ wait_for_busy (self );
351+ self -> refreshing = false;
352+ // Run stop sequence but don't wait for busy because busy is set when sleeping.
353+ send_command_sequence (self , false, self -> stop_sequence , self -> stop_sequence_len );
354+ }
355+
346356 release_display_core (& self -> core );
347357 if (self -> busy .base .type == & digitalio_digitalinout_type ) {
348358 common_hal_digitalio_digitalinout_deinit (& self -> busy );
@@ -352,3 +362,20 @@ void release_epaperdisplay(displayio_epaperdisplay_obj_t* self) {
352362void displayio_epaperdisplay_collect_ptrs (displayio_epaperdisplay_obj_t * self ) {
353363 displayio_display_core_collect_ptrs (& self -> core );
354364}
365+
366+ bool maybe_refresh_epaperdisplay (void ) {
367+ for (uint8_t i = 0 ; i < CIRCUITPY_DISPLAY_LIMIT ; i ++ ) {
368+ if (displays [i ].epaper_display .base .type != & displayio_epaperdisplay_type ||
369+ displays [i ].epaper_display .core .current_group != & circuitpython_splash ) {
370+ // Skip regular displays and those not showing the splash.
371+ continue ;
372+ }
373+ displayio_epaperdisplay_obj_t * display = & displays [i ].epaper_display ;
374+ if (common_hal_displayio_epaperdisplay_get_time_to_refresh (display ) != 0 ) {
375+ return false;
376+ }
377+ return common_hal_displayio_epaperdisplay_refresh (display );
378+ }
379+ // Return true if no ePaper displays are available to pretend it was updated.
380+ return true;
381+ }
0 commit comments