[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) {
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);
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) {
furi_assert(bt);
notification_message(bt->notification, &sequence_display_on);
notification_message(bt->notification, &sequence_display_backlight_on);
string_t pin_str;
dialog_message_set_icon(bt->dialog_message, &I_BLE_Pairing_128x64, 0, 0);
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")) {
notification_led_message.type = NotificationMessageTypeLedBlue;
} else if(!string_cmp(light_name, "bl")) {
notification_led_message.type = NotificationMessageTypeLedDisplay;
notification_led_message.type = NotificationMessageTypeLedDisplayBacklight;
} else {
cli_print_usage("led", "<r|g|b|bl> <0-255>", string_get_cstr(args));
string_clear(light_name);

View File

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

View File

@ -121,7 +121,7 @@ void desktop_lock(Desktop* desktop) {
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER);
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) {

View File

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

View File

@ -89,7 +89,7 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
break;
case DesktopLockedEventUpdate:
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);
consumed = true;

View File

@ -133,7 +133,7 @@ bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) {
case DesktopPinInputEventBack:
scene_manager_search_and_switch_to_previous_scene(
desktop->scene_manager, DesktopSceneLocked);
notification_message(desktop->notification, &sequence_display_off);
notification_message(desktop->notification, &sequence_display_backlight_off);
consumed = true;
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);
scene_manager_set_scene_state(app->scene_manager, GpioSceneUsbUart, 0);
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) {
@ -63,5 +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);
notification_message(app->notifications, &sequence_display_backlight_enforce_auto);
}

View File

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

View File

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

View File

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

View File

@ -9,15 +9,10 @@ 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;
extern const NotificationMessage message_display_backlight_on;
extern const NotificationMessage message_display_backlight_off;
extern const NotificationMessage message_display_backlight_enforce_on;
extern const NotificationMessage message_display_backlight_enforce_auto;
// Led ON
extern const NotificationMessage message_red_255;
@ -71,15 +66,16 @@ extern const NotificationSequence sequence_set_vibro_on;
// Display
/** Display: backlight wakeup */
extern const NotificationSequence sequence_display_on;
extern const NotificationSequence sequence_display_backlight_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;
extern const NotificationSequence sequence_display_backlight_off;
/** 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
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]);
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) {
@ -79,7 +79,7 @@ static void screen_changed(VariableItem* item) {
variable_item_set_current_value_text(item, delay_text[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 = {

View File

@ -28,7 +28,7 @@ static void battery_test_battery_info_update_model(void* context) {
.health = app->info.health,
};
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() {

View File

@ -59,7 +59,7 @@ bool u2f_scene_main_on_event(void* context, SceneManagerEvent event) {
u2f_view_set_state(app->u2f_view, U2fMsgRegister);
else if(event.event == U2fCustomEventAuth)
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_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) {
Updater* updater = (Updater*)context;
notification_message(updater->notification, &sequence_display_backlight_enforce_on);
UpdaterMainView* main_view = updater->main_view;
FuriPubSubSubscription* sub =
@ -92,8 +93,9 @@ bool updater_scene_main_on_event(void* context, SceneManagerEvent event) {
void updater_scene_main_on_exit(void* context) {
Updater* updater = (Updater*)context;
notification_message(updater->notification, &sequence_display_backlight_enforce_auto);
furi_pubsub_unsubscribe(
storage_get_pubsub(updater->storage), updater_main_get_storage_pubsub(updater->main_view));
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->notification = furi_record_open("notification");
updater->gui = furi_record_open("gui");
updater->view_dispatcher = view_dispatcher_alloc();
@ -119,6 +120,7 @@ void updater_free(Updater* updater) {
furi_record_close("gui");
furi_record_close("storage");
furi_record_close("notification");
free(updater);
}

View File

@ -11,6 +11,7 @@
#include <gui/scene_manager.h>
#include <gui/modules/widget.h>
#include <storage/storage.h>
#include <notification/notification_app.h>
#include <update_util/update_operation.h>
#ifdef __cplusplus
@ -41,6 +42,7 @@ typedef struct UpdaterManifestProcessingState {
typedef struct {
// GUI
Gui* gui;
NotificationApp* notification;
SceneManager* scene_manager;
ViewDispatcher* view_dispatcher;
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);
}
if(instance->signal.timings_cnt == 0)
notification_message(instance->notification, &sequence_display_on);
notification_message(instance->notification, &sequence_display_backlight_on);
while(sizeof(LevelDuration) ==
xStreamBufferReceive(
instance->stream, &level_duration, sizeof(LevelDuration), 0)) {