Skip to content

Commit

Permalink
Add modal to turn off screen when charging is detected (#2514)
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketGod-git authored Feb 8, 2025
1 parent b66d8b1 commit 0258610
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,29 @@ void SystemStatusView::on_battery_data(const BatteryStateMessage* msg) {
batt_was_inited = true;
refresh();
}

// Check if charging state changed to charging
static bool was_charging = false;
if (msg->on_charger && !was_charging) {
// Only show charging modal when transitioning to charging state
nav_.display_modal(
"CHARGING",
"Screen on while charging?",
YESNO,
[this](bool keep_screen_on) {
if (!keep_screen_on) {
EventDispatcher::set_display_sleep(true);
}
});
}
was_charging = msg->on_charger;

if (!pmem::ui_hide_numeric_battery()) {
battery_text.set_battery(msg->valid_mask, msg->percent, msg->on_charger);
}
if (!pmem::ui_hide_battery_icon()) {
battery_icon.set_battery(msg->valid_mask, msg->percent, msg->on_charger);
};
}
}

void SystemStatusView::refresh() {
Expand Down

0 comments on commit 0258610

Please sign in to comment.