From 92734f1bb362d450eb26485dca16144817d04d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Thu, 24 Feb 2022 03:17:40 +0300 Subject: [PATCH] Notification: backlight always on lock. Gpio: backlight always on lock in uart brige app. (#1007) --- .../gpio/scenes/gpio_scene_usb_uart.c | 2 ++ applications/notification/notification.h | 10 ++++++++- applications/notification/notification_app.c | 19 ++++++++++++++++ applications/notification/notification_app.h | 2 +- .../notification/notification_messages.c | 22 ++++++++++++++++++- .../notification/notification_messages.h | 13 +++++++++++ 6 files changed, 65 insertions(+), 3 deletions(-) diff --git a/applications/gpio/scenes/gpio_scene_usb_uart.c b/applications/gpio/scenes/gpio_scene_usb_uart.c index e2babcac..8bf900cd 100644 --- a/applications/gpio/scenes/gpio_scene_usb_uart.c +++ b/applications/gpio/scenes/gpio_scene_usb_uart.c @@ -33,6 +33,7 @@ void gpio_scene_usb_uart_on_enter(void* context) { gpio_usb_uart_set_callback(app->gpio_usb_uart, gpio_scene_usb_uart_callback, app); scene_manager_set_scene_state(app->scene_manager, GpioAppViewUsbUart, 0); view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewUsbUart); + notification_message(app->notifications, &sequence_display_lock); } bool gpio_scene_usb_uart_on_event(void* context, SceneManagerEvent event) { @@ -62,4 +63,5 @@ void gpio_scene_usb_uart_on_exit(void* context) { usb_uart_disable(app->usb_uart_bridge); free(scene_usb_uart); } + notification_message(app->notifications, &sequence_display_unlock); } diff --git a/applications/notification/notification.h b/applications/notification/notification.h index 9bb63361..ea10ec23 100644 --- a/applications/notification/notification.h +++ b/applications/notification/notification.h @@ -40,14 +40,22 @@ typedef union { typedef enum { NotificationMessageTypeVibro, + NotificationMessageTypeSoundOn, NotificationMessageTypeSoundOff, + NotificationMessageTypeLedRed, NotificationMessageTypeLedGreen, NotificationMessageTypeLedBlue, + NotificationMessageTypeDelay, + NotificationMessageTypeLedDisplay, + NotificationMessageTypeLedDisplayLock, + NotificationMessageTypeLedDisplayUnlock, + NotificationMessageTypeDoNotReset, + NotificationMessageTypeForceSpeakerVolumeSetting, NotificationMessageTypeForceVibroSetting, NotificationMessageTypeForceDisplayBrightnessSetting, @@ -83,4 +91,4 @@ void notification_internal_message_block( #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/applications/notification/notification_app.c b/applications/notification/notification_app.c index 9dfa4d1a..1fba0571 100644 --- a/applications/notification/notification_app.c +++ b/applications/notification/notification_app.c @@ -163,6 +163,7 @@ void notification_process_notification_message( notification_message = (*message->sequence)[notification_message_index]; bool led_active = false; + uint8_t display_led_lock = 0; uint8_t led_values[NOTIFICATION_LED_COUNT] = {0x00, 0x00, 0x00}; bool reset_notifications = true; float speaker_volume_setting = app->settings.speaker_volume; @@ -189,6 +190,24 @@ void notification_process_notification_message( } reset_mask |= reset_display_mask; break; + case NotificationMessageTypeLedDisplayLock: + furi_assert(display_led_lock < UINT8_MAX); + display_led_lock++; + if(display_led_lock == 1) { + notification_apply_internal_led_layer( + &app->display, + notification_message->data.led.value * display_brightness_setting); + } + break; + case NotificationMessageTypeLedDisplayUnlock: + furi_assert(display_led_lock > 0); + display_led_lock--; + if(display_led_lock == 0) { + notification_apply_internal_led_layer( + &app->display, + notification_message->data.led.value * display_brightness_setting); + } + break; case NotificationMessageTypeLedRed: // store and send on delay or after seq led_active = true; diff --git a/applications/notification/notification_app.h b/applications/notification/notification_app.h index 248a30ec..5b7546aa 100644 --- a/applications/notification/notification_app.h +++ b/applications/notification/notification_app.h @@ -53,4 +53,4 @@ struct NotificationApp { NotificationSettings settings; }; -void notification_message_save_settings(NotificationApp* app); \ No newline at end of file +void notification_message_save_settings(NotificationApp* app); diff --git a/applications/notification/notification_messages.c b/applications/notification/notification_messages.c index b65a05f3..44b005d1 100644 --- a/applications/notification/notification_messages.c +++ b/applications/notification/notification_messages.c @@ -15,6 +15,16 @@ const NotificationMessage message_display_off = { .data.led.value = 0x00, }; +const NotificationMessage message_display_lock = { + .type = NotificationMessageTypeLedDisplayLock, + .data.led.value = 0xFF, +}; + +const NotificationMessage message_display_unlock = { + .type = NotificationMessageTypeLedDisplayLock, + .data.led.value = 0x00, +}; + // Led ON const NotificationMessage message_red_255 = { .type = NotificationMessageTypeLedRed, @@ -188,6 +198,16 @@ const NotificationSequence sequence_display_off = { NULL, }; +const NotificationSequence sequence_display_lock = { + &message_display_lock, + NULL, +}; + +const NotificationSequence sequence_display_unlock = { + &message_display_unlock, + NULL, +}; + // Charging const NotificationSequence sequence_charging = { &message_red_255, @@ -416,4 +436,4 @@ const NotificationSequence sequence_audiovisual_alert = { &message_sound_off, &message_vibro_off, NULL, -}; \ No newline at end of file +}; diff --git a/applications/notification/notification_messages.h b/applications/notification/notification_messages.h index f8f89931..54215e47 100644 --- a/applications/notification/notification_messages.h +++ b/applications/notification/notification_messages.h @@ -9,8 +9,15 @@ extern "C" { /*********************************** Messages **********************************/ // Display + +/** Display: backlight wakeup */ extern const NotificationMessage message_display_on; +/** Display: backlight force off */ extern const NotificationMessage message_display_off; +/** Display: backlight always on lock */ +extern const NotificationMessage message_display_lock; +/** Display: backlight always on unlock */ +extern const NotificationMessage message_display_unlock; // Led ON extern const NotificationMessage message_red_255; @@ -63,8 +70,14 @@ extern const NotificationSequence sequence_reset_vibro; extern const NotificationSequence sequence_set_vibro_on; // Display +/** Display: backlight wakeup */ extern const NotificationSequence sequence_display_on; +/** Display: backlight force off */ extern const NotificationSequence sequence_display_off; +/** Display: backlight always on lock */ +extern const NotificationSequence sequence_display_lock; +/** Display: backlight always on unlock */ +extern const NotificationSequence sequence_display_unlock; // Charging extern const NotificationSequence sequence_charging;