diff --git a/src/main.cpp b/src/main.cpp index a9710f7c..75bf69c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -347,11 +347,6 @@ void loop() { powerManager.setPowerSaving(false); // Restore normal CPU frequency on user activity } - // Refresh the battery icon immediately when USB is plugged or unplugged - if (gpio.wasUsbStateChanged()) { - activityManager.requestUpdate(); - } - static bool screenshotButtonsReleased = true; if (gpio.isPressed(HalGPIO::BTN_POWER) && gpio.isPressed(HalGPIO::BTN_DOWN)) { if (screenshotButtonsReleased) { @@ -384,6 +379,12 @@ void loop() { return; } + // Refresh the battery icon when USB is plugged or unplugged. + // Placed after sleep guards so we never queue a render that won't be processed. + if (gpio.wasUsbStateChanged()) { + activityManager.requestUpdate(); + } + const unsigned long activityStartTime = millis(); activityManager.loop(); const unsigned long activityDuration = millis() - activityStartTime;