@@ -501,36 +501,6 @@ void AppClock::scheduleNextAutoNtp(std::uint32_t delay_ms)
501501 _next_auto_ntp_ms = GetHAL ().millis () + delay_ms;
502502}
503503
504- void AppClock::captureNtpBackground ()
505- {
506- auto & display = GetHAL ().display ;
507- const int screen_w = display.width ();
508- const int screen_h = display.height ();
509- if (screen_w <= 0 || screen_h <= 0 ) {
510- _ntp_background_valid = false ;
511- return ;
512- }
513-
514- const std::size_t buffer_size = static_cast <std::size_t >(screen_w) * static_cast <std::size_t >(screen_h);
515- _ntp_background.resize (buffer_size);
516- display.readRect (0 , 0 , screen_w, screen_h, _ntp_background.data ());
517- _ntp_background_w = static_cast <std::int16_t >(screen_w);
518- _ntp_background_h = static_cast <std::int16_t >(screen_h);
519- _ntp_background_valid = true ;
520- }
521-
522- void AppClock::restoreNtpBackground ()
523- {
524- if (!_ntp_background_valid || _ntp_background.empty ()) {
525- GetHAL ().drawBackground (m5gfx::epd_mode_t ::epd_fastest, false );
526- return ;
527- }
528-
529- auto & display = GetHAL ().display ;
530- display.setEpdMode (m5gfx::epd_mode_t ::epd_fastest);
531- display.pushImage (0 , 0 , _ntp_background_w, _ntp_background_h, _ntp_background.data ());
532- }
533-
534504/* -------------------------------------------------------------------------- */
535505/* Lifecycle */
536506/* -------------------------------------------------------------------------- */
@@ -594,7 +564,7 @@ void AppClock::onRunning()
594564 const auto timezone_date_time = convertRtcToTimezone (date_time, TIMEZONES [_timezone_index]);
595565 minute_changed = makeDisplayMinuteKey (timezone_date_time) != _last_display_minute_key;
596566 }
597- if (!_has_drawn || GetHAL ().isRefreshRequested () || minute_changed ||
567+ if (!_has_drawn || GetHAL ().isFullRedrawRequested () || minute_changed ||
598568 now_ms - _last_update_ms >= CLOCK_REFRESH_MS ) {
599569 drawTime ();
600570 }
@@ -606,7 +576,7 @@ void AppClock::onRunning()
606576
607577void AppClock::openNtpDialog ()
608578{
609- captureNtpBackground ();
579+ GetHAL (). captureDisplaySnapshot ();
610580 _ntp_dialog_open = true ;
611581 _ntp_scan_running = false ;
612582 _ntp_success_close_ms = 0 ;
@@ -619,7 +589,7 @@ void AppClock::openNtpDialog()
619589 WiFi.scanDelete ();
620590 GetHAL ().setUiModalActive (true );
621591 GetHAL ().playBuzzerPattern (NTP_DIALOG_OPEN_TONES , 2 );
622- drawNtpDialog ();
592+ drawNtpDialog (true );
623593}
624594
625595void AppClock::closeNtpDialog ()
@@ -635,13 +605,15 @@ void AppClock::closeNtpDialog()
635605 _ntp_touching = false ;
636606 _ntp_list_touching = false ;
637607 _ntp_list_dragged = false ;
638- restoreNtpBackground ();
639- _has_drawn = false ;
640- _ntp_background_valid = false ;
641- GetHAL ().releaseModalNextFrame ();
608+ if (!GetHAL ().restoreDisplaySnapshot ()) {
609+ GetHAL ().drawBackground (m5gfx::epd_mode_t ::epd_fast, false );
610+ }
611+ GetHAL ().clearDisplaySnapshot ();
612+ _has_drawn = false ;
613+ GetHAL ().releaseModalNextFrame (m5gfx::epd_mode_t ::epd_fast);
642614}
643615
644- void AppClock::drawNtpDialog ()
616+ void AppClock::drawNtpDialog (bool full_refresh )
645617{
646618 auto & display = GetHAL ().display ;
647619 display.setEpdMode (m5gfx::epd_mode_t ::epd_fastest);
@@ -671,7 +643,7 @@ void AppClock::drawNtpDialog()
671643 display.drawString (" AUTO TIME SYNC" , NTP_FIELD_X , NTP_AUTO_Y + NTP_AUTO_H / 2 );
672644 drawNtpToggle (_ntp_auto_enabled, NTP_AUTO_TOGGLE_X , NTP_AUTO_Y , NTP_AUTO_TOGGLE_W , NTP_AUTO_H );
673645
674- drawNtpButton (_ntp_scan_running ? " SCANNING..." : " SCAN NETWORKS " , NTP_SCAN_X , NTP_BUTTON_ROW_Y , NTP_ACTION_W ,
646+ drawNtpButton (_ntp_scan_running ? " SCANNING..." : " SCAN Wi-Fi " , NTP_SCAN_X , NTP_BUTTON_ROW_Y , NTP_ACTION_W ,
675647 NTP_ACTION_H , _ntp_scan_running);
676648 drawNtpButton (_ntp_connecting || _ntp_syncing ? " SYNCING TIME" : " SYNC TIME" , NTP_SYNC_X , NTP_BUTTON_ROW_Y ,
677649 NTP_ACTION_W , NTP_ACTION_H , _ntp_connecting || _ntp_syncing);
@@ -718,8 +690,10 @@ void AppClock::drawNtpDialog()
718690 }
719691 }
720692
693+ display.setEpdMode (full_refresh ? m5gfx::epd_mode_t ::epd_fast : m5gfx::epd_mode_t ::epd_fastest);
721694 GetHAL ().flushDisplay (NTP_DIALOG_X , NTP_DIALOG_Y , NTP_DIALOG_W , NTP_DIALOG_H );
722695 display.waitDisplay ();
696+ display.setEpdMode (m5gfx::epd_mode_t ::epd_fastest);
723697}
724698
725699void AppClock::drawNtpInputFields ()
@@ -757,10 +731,12 @@ void AppClock::handleNtpDialog()
757731 if (_keyboard.isOpen ()) {
758732 auto closeKeyboardAndRedraw = [&]() {
759733 commitNtpKeyboard ();
760- restoreNtpBackground ();
734+ if (!GetHAL ().restoreDisplaySnapshot ()) {
735+ GetHAL ().drawBackground (m5gfx::epd_mode_t ::epd_fast, false );
736+ }
761737 GetHAL ().requestRefresh ();
762738 drawTime ();
763- drawNtpDialog ();
739+ drawNtpDialog (true );
764740 };
765741 auto switchKeyboardField = [&](std::uint8_t field) {
766742 if (_ntp_edit_field == field) {
@@ -845,10 +821,10 @@ void AppClock::handleNtpDialog()
845821 }
846822 _ntp_touching = false ;
847823
848- const int dx = point.x - _ntp_touch_start_x;
849- const int dy = point.y - _ntp_touch_start_y;
850- const bool started_in_list = _ntp_touch_start_x >= NTP_LIST_X && _ntp_touch_start_x <= NTP_LIST_X + NTP_LIST_W &&
851- _ntp_touch_start_y >= NTP_LIST_Y && _ntp_touch_start_y < NTP_LIST_Y + list_h;
824+ const int dx = point.x - _ntp_touch_start_x;
825+ const int dy = point.y - _ntp_touch_start_y;
826+ const bool started_in_list = _ntp_touch_start_x >= NTP_LIST_X && _ntp_touch_start_x <= NTP_LIST_X + NTP_LIST_W &&
827+ _ntp_touch_start_y >= NTP_LIST_Y && _ntp_touch_start_y < NTP_LIST_Y + list_h;
852828 const bool is_vertical_swipe = started_in_list && std::abs (dy) >= NTP_LIST_ROW_H && std::abs (dy) > std::abs (dx);
853829 if (max_scroll > 0 && is_vertical_swipe) {
854830 const int old_scroll = _ntp_list_scroll;
0 commit comments