[FL-2515] Keep backlight on for updater ops (#1184)

* [FL-2515] Keep backlight on for updater ops
* Notification: Renamed backlight sequences to more obvious names

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
hedger 2022-04-29 17:21:12 +03:00 committed by GitHub
parent 01434265f6
commit 7017fa4f9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 77 additions and 70 deletions

View file

@ -60,7 +60,7 @@ static ViewPort* bt_pin_code_view_port_alloc(Bt* bt) {
static void bt_pin_code_show(Bt* bt, uint32_t pin_code) { static void bt_pin_code_show(Bt* bt, uint32_t pin_code) {
bt->pin_code = pin_code; bt->pin_code = pin_code;
notification_message(bt->notification, &sequence_display_on); notification_message(bt->notification, &sequence_display_backlight_on);
gui_view_port_send_to_front(bt->gui, bt->pin_code_view_port); gui_view_port_send_to_front(bt->gui, bt->pin_code_view_port);
view_port_enabled_set(bt->pin_code_view_port, true); view_port_enabled_set(bt->pin_code_view_port, true);
} }
@ -74,7 +74,7 @@ static void bt_pin_code_hide(Bt* bt) {
static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) { static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
furi_assert(bt); furi_assert(bt);
notification_message(bt->notification, &sequence_display_on); notification_message(bt->notification, &sequence_display_backlight_on);
string_t pin_str; string_t pin_str;
dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64, 0, 0); dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64, 0, 0);
string_init_printf(pin_str, "Verify code\n%06d", pin); string_init_printf(pin_str, "Verify code\n%06d", pin);

View file

@ -202,7 +202,7 @@ void cli_command_led(Cli* cli, string_t args, void* context) {
} else if(!string_cmp(light_name, "b")) { } else if(!string_cmp(light_name, "b")) {
notification_led_message.type = NotificationMessageTypeLedBlue; notification_led_message.type = NotificationMessageTypeLedBlue;
} else if(!string_cmp(light_name, "bl")) { } else if(!string_cmp(light_name, "bl")) {
notification_led_message.type = NotificationMessageTypeLedDisplay; notification_led_message.type = NotificationMessageTypeLedDisplayBacklight;
} else { } else {
cli_print_usage("led", "<r|g|b|bl> <0-255>", string_get_cstr(args)); cli_print_usage("led", "<r|g|b|bl> <0-255>", string_get_cstr(args));
string_clear(light_name); string_clear(light_name);

View file

@ -45,7 +45,7 @@ typedef enum {
#define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx) #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
const NotificationSequence sequence_notification = { const NotificationSequence sequence_notification = {
&message_display_on, &message_display_backlight_on,
&message_green_255, &message_green_255,
&message_delay_10, &message_delay_10,
NULL, NULL,

View file

@ -121,7 +121,7 @@ void desktop_lock(Desktop* desktop) {
scene_manager_set_scene_state( scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER); desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked); scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked);
notification_message(desktop->notification, &sequence_display_off_delay_1000); notification_message(desktop->notification, &sequence_display_backlight_off_delay_1000);
} }
void desktop_unlock(Desktop* desktop) { void desktop_unlock(Desktop* desktop) {

View file

@ -11,7 +11,7 @@
#include <cli/cli_vcp.h> #include <cli/cli_vcp.h>
static const NotificationSequence sequence_pin_fail = { static const NotificationSequence sequence_pin_fail = {
&message_display_on, &message_display_backlight_on,
&message_red_255, &message_red_255,
&message_vibro_on, &message_vibro_on,

View file

@ -89,7 +89,7 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
break; break;
case DesktopLockedEventUpdate: case DesktopLockedEventUpdate:
if(desktop_view_locked_is_locked_hint_visible(desktop->locked_view)) { if(desktop_view_locked_is_locked_hint_visible(desktop->locked_view)) {
notification_message(desktop->notification, &sequence_display_off); notification_message(desktop->notification, &sequence_display_backlight_off);
} }
desktop_view_locked_update(desktop->locked_view); desktop_view_locked_update(desktop->locked_view);
consumed = true; consumed = true;

View file

@ -133,7 +133,7 @@ bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) {
case DesktopPinInputEventBack: case DesktopPinInputEventBack:
scene_manager_search_and_switch_to_previous_scene( scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneLocked); desktop->scene_manager, DesktopSceneLocked);
notification_message(desktop->notification, &sequence_display_off); notification_message(desktop->notification, &sequence_display_backlight_off);
consumed = true; consumed = true;
break; break;
} }

View file

@ -33,7 +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); gpio_usb_uart_set_callback(app->gpio_usb_uart, gpio_scene_usb_uart_callback, app);
scene_manager_set_scene_state(app->scene_manager, GpioSceneUsbUart, 0); scene_manager_set_scene_state(app->scene_manager, GpioSceneUsbUart, 0);
view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewUsbUart); view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewUsbUart);
notification_message(app->notifications, &sequence_display_lock); notification_message(app->notifications, &sequence_display_backlight_enforce_on);
} }
bool gpio_scene_usb_uart_on_event(void* context, SceneManagerEvent event) { bool gpio_scene_usb_uart_on_event(void* context, SceneManagerEvent event) {
@ -63,5 +63,5 @@ void gpio_scene_usb_uart_on_exit(void* context) {
usb_uart_disable(app->usb_uart_bridge); usb_uart_disable(app->usb_uart_bridge);
free(scene_usb_uart); free(scene_usb_uart);
} }
notification_message(app->notifications, &sequence_display_unlock); notification_message(app->notifications, &sequence_display_backlight_enforce_auto);
} }

View file

@ -50,9 +50,9 @@ typedef enum {
NotificationMessageTypeDelay, NotificationMessageTypeDelay,
NotificationMessageTypeLedDisplay, NotificationMessageTypeLedDisplayBacklight,
NotificationMessageTypeLedDisplayLock, NotificationMessageTypeLedDisplayBacklightEnforceOn,
NotificationMessageTypeLedDisplayUnlock, NotificationMessageTypeLedDisplayBacklightEnforceAuto,
NotificationMessageTypeDoNotReset, NotificationMessageTypeDoNotReset,

View file

@ -152,7 +152,7 @@ void notification_sound_off() {
static void notification_display_timer(void* ctx) { static void notification_display_timer(void* ctx) {
furi_assert(ctx); furi_assert(ctx);
NotificationApp* app = ctx; NotificationApp* app = ctx;
notification_message(app, &sequence_display_off); notification_message(app, &sequence_display_backlight_off);
} }
// message processing // message processing
@ -174,7 +174,7 @@ void notification_process_notification_message(
while(notification_message != NULL) { while(notification_message != NULL) {
switch(notification_message->type) { switch(notification_message->type) {
case NotificationMessageTypeLedDisplay: case NotificationMessageTypeLedDisplayBacklight:
// if on - switch on and start timer // if on - switch on and start timer
// if off - switch off and stop timer // if off - switch off and stop timer
// on timer - switch off // on timer - switch off
@ -190,7 +190,7 @@ void notification_process_notification_message(
} }
reset_mask |= reset_display_mask; reset_mask |= reset_display_mask;
break; break;
case NotificationMessageTypeLedDisplayLock: case NotificationMessageTypeLedDisplayBacklightEnforceOn:
furi_assert(app->display_led_lock < UINT8_MAX); furi_assert(app->display_led_lock < UINT8_MAX);
app->display_led_lock++; app->display_led_lock++;
if(app->display_led_lock == 1) { if(app->display_led_lock == 1) {
@ -199,7 +199,7 @@ void notification_process_notification_message(
notification_message->data.led.value * display_brightness_setting); notification_message->data.led.value * display_brightness_setting);
} }
break; break;
case NotificationMessageTypeLedDisplayUnlock: case NotificationMessageTypeLedDisplayBacklightEnforceAuto:
furi_assert(app->display_led_lock > 0); furi_assert(app->display_led_lock > 0);
app->display_led_lock--; app->display_led_lock--;
if(app->display_led_lock == 0) { if(app->display_led_lock == 0) {
@ -322,7 +322,7 @@ void notification_process_internal_message(NotificationApp* app, NotificationApp
while(notification_message != NULL) { while(notification_message != NULL) {
switch(notification_message->type) { switch(notification_message->type) {
case NotificationMessageTypeLedDisplay: case NotificationMessageTypeLedDisplayBacklight:
notification_apply_internal_led_layer( notification_apply_internal_led_layer(
&app->display, &app->display,
notification_settings_get_display_brightness( notification_settings_get_display_brightness(
@ -442,7 +442,7 @@ static void input_event_callback(const void* value, void* context) {
furi_assert(value); furi_assert(value);
furi_assert(context); furi_assert(context);
NotificationApp* app = context; NotificationApp* app = context;
notification_message(app, &sequence_display_on); notification_message(app, &sequence_display_backlight_on);
} }
// App alloc // App alloc
@ -482,7 +482,7 @@ static NotificationApp* notification_app_alloc() {
// display backlight control // display backlight control
app->event_record = furi_record_open("input_events"); app->event_record = furi_record_open("input_events");
furi_pubsub_subscribe(app->event_record, input_event_callback, app); furi_pubsub_subscribe(app->event_record, input_event_callback, app);
notification_message(app, &sequence_display_on); notification_message(app, &sequence_display_backlight_on);
return app; return app;
}; };

View file

@ -4,24 +4,27 @@
/*********************************** Messages **********************************/ /*********************************** Messages **********************************/
// Display /** Display: backlight wakeup */
const NotificationMessage message_display_on = { const NotificationMessage message_display_backlight_on = {
.type = NotificationMessageTypeLedDisplay, .type = NotificationMessageTypeLedDisplayBacklight,
.data.led.value = 0xFF, .data.led.value = 0xFF,
}; };
const NotificationMessage message_display_off = { /** Display: backlight force off */
.type = NotificationMessageTypeLedDisplay, const NotificationMessage message_display_backlight_off = {
.type = NotificationMessageTypeLedDisplayBacklight,
.data.led.value = 0x00, .data.led.value = 0x00,
}; };
const NotificationMessage message_display_lock = { /** Display: backlight always on */
.type = NotificationMessageTypeLedDisplayLock, const NotificationMessage message_display_backlight_enforce_on = {
.type = NotificationMessageTypeLedDisplayBacklightEnforceOn,
.data.led.value = 0xFF, .data.led.value = 0xFF,
}; };
const NotificationMessage message_display_unlock = { /** Display: automatic backlight management, with configured timeout */
.type = NotificationMessageTypeLedDisplayUnlock, const NotificationMessage message_display_backlight_enforce_auto = {
.type = NotificationMessageTypeLedDisplayBacklightEnforceAuto,
.data.led.value = 0x00, .data.led.value = 0x00,
}; };
@ -166,7 +169,7 @@ const NotificationSequence sequence_reset_rgb = {
}; };
const NotificationSequence sequence_reset_display = { const NotificationSequence sequence_reset_display = {
&message_display_off, &message_display_backlight_off,
NULL, NULL,
}; };
@ -188,29 +191,31 @@ const NotificationSequence sequence_set_vibro_on = {
}; };
// Display // Display
const NotificationSequence sequence_display_on = { const NotificationSequence sequence_display_backlight_on = {
&message_display_on, &message_display_backlight_on,
NULL, NULL,
}; };
const NotificationSequence sequence_display_off = { const NotificationSequence sequence_display_backlight_off = {
&message_display_off, &message_display_backlight_off,
NULL, NULL,
}; };
const NotificationSequence sequence_display_lock = { /** Display: backlight always on lock */
&message_display_lock, const NotificationSequence sequence_display_backlight_enforce_on = {
&message_display_backlight_enforce_on,
NULL, NULL,
}; };
const NotificationSequence sequence_display_unlock = { /** Display: backlight always on unlock */
&message_display_unlock, const NotificationSequence sequence_display_backlight_enforce_auto = {
&message_display_backlight_enforce_auto,
NULL, NULL,
}; };
const NotificationSequence sequence_display_off_delay_1000 = { const NotificationSequence sequence_display_backlight_off_delay_1000 = {
&message_delay_1000, &message_delay_1000,
&message_display_off, &message_display_backlight_off,
NULL, NULL,
}; };
@ -383,7 +388,7 @@ const NotificationSequence sequence_double_vibro = {
}; };
const NotificationSequence sequence_success = { const NotificationSequence sequence_success = {
&message_display_on, &message_display_backlight_on,
&message_green_255, &message_green_255,
&message_vibro_on, &message_vibro_on,
&message_note_c5, &message_note_c5,
@ -400,7 +405,7 @@ const NotificationSequence sequence_success = {
}; };
const NotificationSequence sequence_error = { const NotificationSequence sequence_error = {
&message_display_on, &message_display_backlight_on,
&message_red_255, &message_red_255,
&message_vibro_on, &message_vibro_on,
&message_note_c5, &message_note_c5,
@ -422,27 +427,27 @@ const NotificationSequence sequence_audiovisual_alert = {
&message_force_display_brightness_setting_1f, &message_force_display_brightness_setting_1f,
&message_vibro_on, &message_vibro_on,
&message_display_on, &message_display_backlight_on,
&message_note_c7, &message_note_c7,
&message_delay_250, &message_delay_250,
&message_display_off, &message_display_backlight_off,
&message_note_c4, &message_note_c4,
&message_delay_250, &message_delay_250,
&message_display_on, &message_display_backlight_on,
&message_note_c7, &message_note_c7,
&message_delay_250, &message_delay_250,
&message_display_off, &message_display_backlight_off,
&message_note_c4, &message_note_c4,
&message_delay_250, &message_delay_250,
&message_display_on, &message_display_backlight_on,
&message_note_c7, &message_note_c7,
&message_delay_250, &message_delay_250,
&message_display_off, &message_display_backlight_off,
&message_note_c4, &message_note_c4,
&message_delay_250, &message_delay_250,

View file

@ -9,15 +9,10 @@ extern "C" {
/*********************************** Messages **********************************/ /*********************************** Messages **********************************/
// Display // Display
extern const NotificationMessage message_display_backlight_on;
/** Display: backlight wakeup */ extern const NotificationMessage message_display_backlight_off;
extern const NotificationMessage message_display_on; extern const NotificationMessage message_display_backlight_enforce_on;
/** Display: backlight force off */ extern const NotificationMessage message_display_backlight_enforce_auto;
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 // Led ON
extern const NotificationMessage message_red_255; extern const NotificationMessage message_red_255;
@ -71,15 +66,16 @@ extern const NotificationSequence sequence_set_vibro_on;
// Display // Display
/** Display: backlight wakeup */ /** Display: backlight wakeup */
extern const NotificationSequence sequence_display_on; extern const NotificationSequence sequence_display_backlight_on;
/** Display: backlight force off */ /** Display: backlight force off */
extern const NotificationSequence sequence_display_off; extern const NotificationSequence sequence_display_backlight_off;
/** Display: backlight always on lock */
extern const NotificationSequence sequence_display_lock;
/** Display: backlight always on unlock */
extern const NotificationSequence sequence_display_unlock;
/** Display: backlight force off after a delay of 1000ms */ /** Display: backlight force off after a delay of 1000ms */
extern const NotificationSequence sequence_display_off_delay_1000; extern const NotificationSequence sequence_display_backlight_off_delay_1000;
/** Display: backlight always on lock */
extern const NotificationSequence sequence_display_backlight_enforce_on;
/** Display: backlight always on unlock */
extern const NotificationSequence sequence_display_backlight_enforce_auto;
// Charging // Charging
extern const NotificationSequence sequence_charging; extern const NotificationSequence sequence_charging;

View file

@ -70,7 +70,7 @@ static void backlight_changed(VariableItem* item) {
variable_item_set_current_value_text(item, backlight_text[index]); variable_item_set_current_value_text(item, backlight_text[index]);
app->notification->settings.display_brightness = backlight_value[index]; app->notification->settings.display_brightness = backlight_value[index];
notification_message(app->notification, &sequence_display_on); notification_message(app->notification, &sequence_display_backlight_on);
} }
static void screen_changed(VariableItem* item) { static void screen_changed(VariableItem* item) {
@ -79,7 +79,7 @@ static void screen_changed(VariableItem* item) {
variable_item_set_current_value_text(item, delay_text[index]); variable_item_set_current_value_text(item, delay_text[index]);
app->notification->settings.display_off_delay_ms = delay_value[index]; app->notification->settings.display_off_delay_ms = delay_value[index];
notification_message(app->notification, &sequence_display_on); notification_message(app->notification, &sequence_display_backlight_on);
} }
const NotificationMessage apply_message = { const NotificationMessage apply_message = {

View file

@ -28,7 +28,7 @@ static void battery_test_battery_info_update_model(void* context) {
.health = app->info.health, .health = app->info.health,
}; };
battery_info_set_data(app->batery_info, &battery_info_data); battery_info_set_data(app->batery_info, &battery_info_data);
notification_message(app->notifications, &sequence_display_on); notification_message(app->notifications, &sequence_display_backlight_on);
} }
BatteryTestApp* battery_test_alloc() { BatteryTestApp* battery_test_alloc() {

View file

@ -59,7 +59,7 @@ bool u2f_scene_main_on_event(void* context, SceneManagerEvent event) {
u2f_view_set_state(app->u2f_view, U2fMsgRegister); u2f_view_set_state(app->u2f_view, U2fMsgRegister);
else if(event.event == U2fCustomEventAuth) else if(event.event == U2fCustomEventAuth)
u2f_view_set_state(app->u2f_view, U2fMsgAuth); u2f_view_set_state(app->u2f_view, U2fMsgAuth);
notification_message(app->notifications, &sequence_display_on); notification_message(app->notifications, &sequence_display_backlight_on);
notification_message(app->notifications, &sequence_single_vibro); notification_message(app->notifications, &sequence_single_vibro);
} }
notification_message(app->notifications, &sequence_blink_magenta_10); notification_message(app->notifications, &sequence_blink_magenta_10);

View file

@ -25,6 +25,7 @@ static void sd_mount_callback(const void* message, void* context) {
void updater_scene_main_on_enter(void* context) { void updater_scene_main_on_enter(void* context) {
Updater* updater = (Updater*)context; Updater* updater = (Updater*)context;
notification_message(updater->notification, &sequence_display_backlight_enforce_on);
UpdaterMainView* main_view = updater->main_view; UpdaterMainView* main_view = updater->main_view;
FuriPubSubSubscription* sub = FuriPubSubSubscription* sub =
@ -92,8 +93,9 @@ bool updater_scene_main_on_event(void* context, SceneManagerEvent event) {
void updater_scene_main_on_exit(void* context) { void updater_scene_main_on_exit(void* context) {
Updater* updater = (Updater*)context; Updater* updater = (Updater*)context;
notification_message(updater->notification, &sequence_display_backlight_enforce_auto);
furi_pubsub_unsubscribe( furi_pubsub_unsubscribe(
storage_get_pubsub(updater->storage), updater_main_get_storage_pubsub(updater->main_view)); storage_get_pubsub(updater->storage), updater_main_get_storage_pubsub(updater->main_view));
scene_manager_set_scene_state(updater->scene_manager, UpdaterSceneMain, 0); scene_manager_set_scene_state(updater->scene_manager, UpdaterSceneMain, 0);
} }

View file

@ -47,6 +47,7 @@ Updater* updater_alloc(const char* arg) {
} }
updater->storage = furi_record_open("storage"); updater->storage = furi_record_open("storage");
updater->notification = furi_record_open("notification");
updater->gui = furi_record_open("gui"); updater->gui = furi_record_open("gui");
updater->view_dispatcher = view_dispatcher_alloc(); updater->view_dispatcher = view_dispatcher_alloc();
@ -119,6 +120,7 @@ void updater_free(Updater* updater) {
furi_record_close("gui"); furi_record_close("gui");
furi_record_close("storage"); furi_record_close("storage");
furi_record_close("notification");
free(updater); free(updater);
} }

View file

@ -11,6 +11,7 @@
#include <gui/scene_manager.h> #include <gui/scene_manager.h>
#include <gui/modules/widget.h> #include <gui/modules/widget.h>
#include <storage/storage.h> #include <storage/storage.h>
#include <notification/notification_app.h>
#include <update_util/update_operation.h> #include <update_util/update_operation.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -41,6 +42,7 @@ typedef struct UpdaterManifestProcessingState {
typedef struct { typedef struct {
// GUI // GUI
Gui* gui; Gui* gui;
NotificationApp* notification;
SceneManager* scene_manager; SceneManager* scene_manager;
ViewDispatcher* view_dispatcher; ViewDispatcher* view_dispatcher;
Storage* storage; Storage* storage;

View file

@ -177,7 +177,7 @@ static int32_t infrared_worker_rx_thread(void* thread_context) {
notification_message(instance->notification, &sequence_blink_blue_10); notification_message(instance->notification, &sequence_blink_blue_10);
} }
if(instance->signal.timings_cnt == 0) if(instance->signal.timings_cnt == 0)
notification_message(instance->notification, &sequence_display_on); notification_message(instance->notification, &sequence_display_backlight_on);
while(sizeof(LevelDuration) == while(sizeof(LevelDuration) ==
xStreamBufferReceive( xStreamBufferReceive(
instance->stream, &level_duration, sizeof(LevelDuration), 0)) { instance->stream, &level_duration, sizeof(LevelDuration), 0)) {