mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 09:18:35 -07:00
Auto_poweroff option moved from desktop to power.
Add settings for power service (load|save).
This commit is contained in:
@@ -19,12 +19,6 @@ static void desktop_auto_lock_arm(Desktop*);
|
||||
static void desktop_auto_lock_inhibit(Desktop*);
|
||||
static void desktop_start_auto_lock_timer(Desktop*);
|
||||
static void desktop_apply_settings(Desktop*);
|
||||
//--- auto_power_off_timer
|
||||
#include <power/power_service/power.h>
|
||||
static void desktop_start_auto_poweroff_timer(Desktop*);
|
||||
static void desktop_auto_poweroff_arm(Desktop*);
|
||||
static void desktop_auto_poweroff_inhibit(Desktop*);
|
||||
//---
|
||||
|
||||
static void desktop_loader_callback(const void* message, void* context) {
|
||||
furi_assert(context);
|
||||
@@ -137,9 +131,7 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
||||
}
|
||||
|
||||
desktop_auto_lock_inhibit(desktop);
|
||||
//--- auto_power_off_timer
|
||||
desktop_auto_poweroff_inhibit(desktop);
|
||||
//--
|
||||
|
||||
desktop->app_running = true;
|
||||
|
||||
furi_semaphore_release(desktop->animation_semaphore);
|
||||
@@ -147,20 +139,12 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
||||
} else if(event == DesktopGlobalAfterAppFinished) {
|
||||
animation_manager_load_and_continue_animation(desktop->animation_manager);
|
||||
desktop_auto_lock_arm(desktop);
|
||||
//--- auto_power_off_timer
|
||||
desktop_auto_poweroff_arm(desktop);
|
||||
//---
|
||||
desktop->app_running = false;
|
||||
|
||||
} else if(event == DesktopGlobalAutoLock) {
|
||||
if(!desktop->app_running && !desktop->locked) {
|
||||
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) {
|
||||
desktop_settings_save(&desktop->settings);
|
||||
desktop_apply_settings(desktop);
|
||||
@@ -195,9 +179,6 @@ static void desktop_input_event_callback(const void* value, void* context) {
|
||||
Desktop* desktop = context;
|
||||
if(event->type == InputTypePress) {
|
||||
desktop_start_auto_lock_timer(desktop);
|
||||
//--- auto_power_off_timer
|
||||
desktop_start_auto_poweroff_timer(desktop);
|
||||
//---
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,41 +215,6 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) {
|
||||
}
|
||||
}
|
||||
|
||||
//--- auto_power_off_timer
|
||||
static void desktop_auto_poweroff_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Desktop* desktop = context;
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAutoPowerOff);
|
||||
}
|
||||
|
||||
static void desktop_start_auto_poweroff_timer(Desktop* desktop) {
|
||||
furi_timer_start(
|
||||
desktop->auto_poweroff_timer, furi_ms_to_ticks(desktop->settings.auto_poweroff_delay_ms));
|
||||
}
|
||||
|
||||
static void desktop_stop_auto_poweroff_timer(Desktop* desktop) {
|
||||
furi_timer_stop(desktop->auto_poweroff_timer);
|
||||
}
|
||||
|
||||
static void desktop_auto_poweroff_arm(Desktop* desktop) {
|
||||
if(desktop->settings.auto_poweroff_delay_ms) {
|
||||
if(!desktop->input_events_subscription) {
|
||||
desktop->input_events_subscription = furi_pubsub_subscribe(
|
||||
desktop->input_events_pubsub, desktop_input_event_callback, desktop);
|
||||
}
|
||||
desktop_start_auto_poweroff_timer(desktop);
|
||||
}
|
||||
}
|
||||
|
||||
static void desktop_auto_poweroff_inhibit(Desktop* desktop) {
|
||||
desktop_stop_auto_poweroff_timer(desktop);
|
||||
if(desktop->input_events_subscription) {
|
||||
furi_pubsub_unsubscribe(desktop->input_events_pubsub, desktop->input_events_subscription);
|
||||
desktop->input_events_subscription = NULL;
|
||||
}
|
||||
}
|
||||
//---
|
||||
|
||||
static void desktop_clock_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Desktop* desktop = context;
|
||||
@@ -294,9 +240,6 @@ static void desktop_apply_settings(Desktop* desktop) {
|
||||
|
||||
if(!desktop->app_running && !desktop->locked) {
|
||||
desktop_auto_lock_arm(desktop);
|
||||
//--- auto_power_off_timer
|
||||
desktop_auto_poweroff_arm(desktop);
|
||||
//---
|
||||
}
|
||||
|
||||
desktop->in_transition = false;
|
||||
@@ -432,10 +375,6 @@ static Desktop* desktop_alloc(void) {
|
||||
|
||||
desktop->auto_lock_timer =
|
||||
furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop);
|
||||
//--- auto_power_off_timer
|
||||
desktop->auto_poweroff_timer =
|
||||
furi_timer_alloc(desktop_auto_poweroff_timer_callback, FuriTimerTypeOnce, desktop);
|
||||
//---
|
||||
|
||||
desktop->status_pubsub = furi_pubsub_alloc();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user