Skip to content

Commit

Permalink
[FL-2515] Keep backlight on for updater ops (flipperdevices#1184)
Browse files Browse the repository at this point in the history
* [FL-2515] Keep backlight on for updater ops
* Notification: Renamed backlight sequences to more obvious names

Co-authored-by: あく <[email protected]>
  • Loading branch information
hedger and skotopes authored Apr 29, 2022
1 parent 0143426 commit 7017fa4
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 69 deletions.
4 changes: 2 additions & 2 deletions applications/bt/bt_service/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/cli/cli_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/debug_tools/uart_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion applications/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion applications/desktop/helpers/pin_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion applications/desktop/scenes/desktop_scene_locked.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion applications/desktop/scenes/desktop_scene_pin_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions applications/gpio/scenes/gpio_scene_usb_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
6 changes: 3 additions & 3 deletions applications/notification/notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ typedef enum {

NotificationMessageTypeDelay,

NotificationMessageTypeLedDisplay,
NotificationMessageTypeLedDisplayLock,
NotificationMessageTypeLedDisplayUnlock,
NotificationMessageTypeLedDisplayBacklight,
NotificationMessageTypeLedDisplayBacklightEnforceOn,
NotificationMessageTypeLedDisplayBacklightEnforceAuto,

NotificationMessageTypeDoNotReset,

Expand Down
14 changes: 7 additions & 7 deletions applications/notification/notification_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
};
Expand Down
61 changes: 33 additions & 28 deletions applications/notification/notification_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -166,7 +169,7 @@ const NotificationSequence sequence_reset_rgb = {
};

const NotificationSequence sequence_reset_display = {
&message_display_off,
&message_display_backlight_off,
NULL,
};

Expand All @@ -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,
};

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,

Expand Down
26 changes: 11 additions & 15 deletions applications/notification/notification_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
extern const NotificationSequence sequence_display_backlight_off;
/** Display: backlight force off after a delay of 1000ms */
extern const NotificationSequence sequence_display_backlight_off_delay_1000;

/** Display: backlight always on lock */
extern const NotificationSequence sequence_display_lock;
extern const NotificationSequence sequence_display_backlight_enforce_on;
/** Display: backlight always on unlock */
extern const NotificationSequence sequence_display_unlock;
/** Display: backlight force off after a delay of 1000ms */
extern const NotificationSequence sequence_display_off_delay_1000;
extern const NotificationSequence sequence_display_backlight_enforce_auto;

// Charging
extern const NotificationSequence sequence_charging;
Expand Down
4 changes: 2 additions & 2 deletions applications/notification/notification_settings_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion applications/power/battery_test_app/battery_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion applications/u2f/scenes/u2f_scene_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 7017fa4

Please sign in to comment.