From fe66f39ecca344f9af4e02bfadccd8e92e58ce16 Mon Sep 17 00:00:00 2001 From: Xiaoxia Date: Fri, 13 Feb 2026 16:18:05 +0800 Subject: [PATCH] Update low battery popup handling in LvglDisplay class (#1765) - Adjusted the logic to check for low battery popup visibility only during clock tick events, ensuring it does not trigger during initialization when battery level is not ready. - Implemented a scheduled task to play the low battery sound, improving responsiveness and avoiding immediate playback during UI updates. --- main/display/lvgl_display/lvgl_display.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main/display/lvgl_display/lvgl_display.cc b/main/display/lvgl_display/lvgl_display.cc index 25f72e5f..46668ddf 100644 --- a/main/display/lvgl_display/lvgl_display.cc +++ b/main/display/lvgl_display/lvgl_display.cc @@ -174,11 +174,15 @@ void LvglDisplay::UpdateStatusBar(bool update_all) { lv_label_set_text(battery_label_, battery_icon_); } - if (low_battery_popup_ != nullptr) { + // Check low battery popup only when clock tick event is triggered + // Because when initializing, the battery level is not ready yet. + if (low_battery_popup_ != nullptr && !update_all) { if (strcmp(icon, FONT_AWESOME_BATTERY_EMPTY) == 0 && discharging) { if (lv_obj_has_flag(low_battery_popup_, LV_OBJ_FLAG_HIDDEN)) { // Show if low battery popup is hidden lv_obj_remove_flag(low_battery_popup_, LV_OBJ_FLAG_HIDDEN); - app.PlaySound(Lang::Sounds::OGG_LOW_BATTERY); + app.Schedule([&app]() { + app.PlaySound(Lang::Sounds::OGG_LOW_BATTERY); + }); } } else { // Hide the low battery popup when the battery is not empty