1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00

use event system

This commit is contained in:
MX
2024-12-24 14:04:34 +03:00
parent 189c87cb08
commit 7fc34db57b
2 changed files with 9 additions and 4 deletions

View File

@@ -156,7 +156,11 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
if(!desktop->app_running && !desktop->locked) { if(!desktop->app_running && !desktop->locked) {
desktop_lock(desktop); desktop_lock(desktop);
} }
} else if(event == DesktopGlobalAutoPowerOff) {
if(!desktop->app_running) {
Power* power = furi_record_open(RECORD_POWER);
power_off(power);
}
} else if(event == DesktopGlobalSaveSettings) { } else if(event == DesktopGlobalSaveSettings) {
desktop_settings_save(&desktop->settings); desktop_settings_save(&desktop->settings);
desktop_apply_settings(desktop); desktop_apply_settings(desktop);
@@ -232,9 +236,9 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) {
//--- auto_power_off_timer //--- auto_power_off_timer
static void desktop_auto_poweroff_timer_callback(void* context) { static void desktop_auto_poweroff_timer_callback(void* context) {
UNUSED(context); furi_assert(context);
Power* power = furi_record_open(RECORD_POWER); Desktop* desktop = context;
power_off(power); view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAutoPowerOff);
} }
static void desktop_start_auto_poweroff_timer(Desktop* desktop) { static void desktop_start_auto_poweroff_timer(Desktop* desktop) {

View File

@@ -62,4 +62,5 @@ typedef enum {
DesktopGlobalApiUnlock, DesktopGlobalApiUnlock,
DesktopGlobalSaveSettings, DesktopGlobalSaveSettings,
DesktopGlobalReloadSettings, DesktopGlobalReloadSettings,
DesktopGlobalAutoPowerOff,
} DesktopEvent; } DesktopEvent;