mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-10 05:59:08 -07:00
Inhibit auto lock/shutdown on ASCII input
This commit is contained in:
@@ -145,14 +145,12 @@ static void desktop_tick_event_callback(void* context) {
|
||||
scene_manager_handle_tick_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static void desktop_input_event_callback(const void* value, void* context) {
|
||||
static void desktop_auto_lock_callback(const void* value, void* context) {
|
||||
furi_assert(value);
|
||||
furi_assert(context);
|
||||
const InputEvent* event = value;
|
||||
UNUSED(value);
|
||||
Desktop* desktop = context;
|
||||
if(event->type == InputTypePress) {
|
||||
desktop_start_auto_lock_timer(desktop);
|
||||
}
|
||||
desktop_start_auto_lock_timer(desktop);
|
||||
}
|
||||
|
||||
static void desktop_auto_lock_timer_callback(void* context) {
|
||||
@@ -172,8 +170,14 @@ static void desktop_stop_auto_lock_timer(Desktop* desktop) {
|
||||
|
||||
static void desktop_auto_lock_arm(Desktop* desktop) {
|
||||
if(desktop->settings.auto_lock_delay_ms) {
|
||||
desktop->input_events_subscription = furi_pubsub_subscribe(
|
||||
desktop->input_events_pubsub, desktop_input_event_callback, desktop);
|
||||
if(desktop->input_events_subscription == NULL) {
|
||||
desktop->input_events_subscription = furi_pubsub_subscribe(
|
||||
desktop->input_events_pubsub, desktop_auto_lock_callback, desktop);
|
||||
}
|
||||
if(desktop->ascii_events_subscription == NULL) {
|
||||
desktop->ascii_events_subscription = furi_pubsub_subscribe(
|
||||
desktop->ascii_events_pubsub, desktop_auto_lock_callback, desktop);
|
||||
}
|
||||
desktop_start_auto_lock_timer(desktop);
|
||||
}
|
||||
}
|
||||
@@ -184,6 +188,10 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) {
|
||||
furi_pubsub_unsubscribe(desktop->input_events_pubsub, desktop->input_events_subscription);
|
||||
desktop->input_events_subscription = NULL;
|
||||
}
|
||||
if(desktop->ascii_events_subscription) {
|
||||
furi_pubsub_unsubscribe(desktop->ascii_events_pubsub, desktop->ascii_events_subscription);
|
||||
desktop->ascii_events_subscription = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void desktop_clock_timer_callback(void* context) {
|
||||
@@ -372,6 +380,8 @@ Desktop* desktop_alloc() {
|
||||
|
||||
desktop->input_events_pubsub = furi_record_open(RECORD_INPUT_EVENTS);
|
||||
desktop->input_events_subscription = NULL;
|
||||
desktop->ascii_events_pubsub = furi_record_open(RECORD_ASCII_EVENTS);
|
||||
desktop->ascii_events_subscription = NULL;
|
||||
|
||||
desktop->auto_lock_timer =
|
||||
furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop);
|
||||
|
||||
@@ -82,6 +82,9 @@ struct Desktop {
|
||||
bool in_transition : 1;
|
||||
|
||||
Keybind keybinds[KeybindTypeCount][KeybindKeyCount];
|
||||
|
||||
FuriPubSub* ascii_events_pubsub;
|
||||
FuriPubSubSubscription* ascii_events_subscription;
|
||||
};
|
||||
|
||||
Desktop* desktop_alloc();
|
||||
|
||||
@@ -261,21 +261,23 @@ static uint32_t power_is_running_auto_shutdown_timer(Power* power) {
|
||||
return furi_timer_is_running(power->auto_shutdown_timer);
|
||||
}
|
||||
|
||||
static void power_input_event_callback(const void* value, void* context) {
|
||||
static void power_auto_shutdown_callback(const void* value, void* context) {
|
||||
furi_assert(value);
|
||||
furi_assert(context);
|
||||
const InputEvent* event = value;
|
||||
UNUSED(value);
|
||||
Power* power = context;
|
||||
if(event->type == InputTypePress) {
|
||||
power_start_auto_shutdown_timer(power);
|
||||
}
|
||||
power_start_auto_shutdown_timer(power);
|
||||
}
|
||||
|
||||
static void power_auto_shutdown_arm(Power* power) {
|
||||
if(power->shutdown_idle_delay_ms) {
|
||||
if(power->input_events_subscription == NULL) {
|
||||
power->input_events_subscription = furi_pubsub_subscribe(
|
||||
power->input_events_pubsub, power_input_event_callback, power);
|
||||
power->input_events_pubsub, power_auto_shutdown_callback, power);
|
||||
}
|
||||
if(power->ascii_events_subscription == NULL) {
|
||||
power->ascii_events_subscription = furi_pubsub_subscribe(
|
||||
power->ascii_events_pubsub, power_auto_shutdown_callback, power);
|
||||
}
|
||||
power_start_auto_shutdown_timer(power);
|
||||
}
|
||||
@@ -287,6 +289,10 @@ static void power_auto_shutdown_inhibit(Power* power) {
|
||||
furi_pubsub_unsubscribe(power->input_events_pubsub, power->input_events_subscription);
|
||||
power->input_events_subscription = NULL;
|
||||
}
|
||||
if(power->ascii_events_subscription) {
|
||||
furi_pubsub_unsubscribe(power->ascii_events_pubsub, power->ascii_events_subscription);
|
||||
power->ascii_events_subscription = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void power_loader_callback(const void* message, void* context) {
|
||||
@@ -333,6 +339,8 @@ Power* power_alloc() {
|
||||
power->loader = furi_record_open(RECORD_LOADER);
|
||||
power->input_events_pubsub = furi_record_open(RECORD_INPUT_EVENTS);
|
||||
power->input_events_subscription = NULL;
|
||||
power->ascii_events_pubsub = furi_record_open(RECORD_ASCII_EVENTS);
|
||||
power->ascii_events_subscription = NULL;
|
||||
power->app_start_stop_subscription =
|
||||
furi_pubsub_subscribe(loader_get_pubsub(power->loader), power_loader_callback, power);
|
||||
power->settings_events_subscription =
|
||||
|
||||
@@ -47,6 +47,8 @@ struct Power {
|
||||
FuriPubSub* settings_events;
|
||||
FuriPubSub* input_events_pubsub;
|
||||
FuriPubSubSubscription* input_events_subscription;
|
||||
FuriPubSub* ascii_events_pubsub;
|
||||
FuriPubSubSubscription* ascii_events_subscription;
|
||||
FuriPubSubSubscription* app_start_stop_subscription;
|
||||
FuriPubSubSubscription* settings_events_subscription;
|
||||
uint32_t shutdown_idle_delay_ms;
|
||||
|
||||
Reference in New Issue
Block a user