mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 23:38:36 -07:00
Inhibit auto lock/shutdown on ASCII input
This commit is contained in:
@@ -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