Inhibit auto lock/shutdown on ASCII input

This commit is contained in:
Willy-JL
2024-01-17 22:43:36 +00:00
parent 9d877eb59d
commit 3406f005c4
4 changed files with 36 additions and 13 deletions

View File

@@ -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 =

View File

@@ -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;