diff --git a/applications/services/notification/notification.h b/applications/services/notification/notification.h index 0e1c07e5d..54e1eb895 100644 --- a/applications/services/notification/notification.h +++ b/applications/services/notification/notification.h @@ -65,6 +65,7 @@ typedef enum { NotificationMessageTypeDelay, NotificationMessageTypeLedDisplayBacklight, + NotificationMessageTypeLedDisplayBacklightForceOn, NotificationMessageTypeLedDisplayBacklightEnforceOn, NotificationMessageTypeLedDisplayBacklightEnforceAuto, diff --git a/applications/services/notification/notification_app.c b/applications/services/notification/notification_app.c index 97a7401a8..8a62f7ac9 100644 --- a/applications/services/notification/notification_app.c +++ b/applications/services/notification/notification_app.c @@ -248,7 +248,7 @@ void night_shift_timer_start(NotificationApp* app) { if(furi_timer_is_running(app->night_shift_timer)) { furi_timer_stop(app->night_shift_timer); } - furi_timer_start(app->night_shift_timer, furi_ms_to_ticks(2000)); + furi_timer_start(app->night_shift_timer, furi_ms_to_ticks(1000)); } } @@ -277,6 +277,12 @@ void night_shift_timer_callback(void* context) { } } +// force backlight ON when night_shift_demo_timer will be ended +void night_shift_demo_timer_callback(void* context) { + furi_assert(context); + NotificationApp* app = context; + notification_message(app, &sequence_display_backlight_force_on); +} // --- NIGHT SHIFT END --- void notification_message_save_settings(NotificationApp* app) { @@ -498,6 +504,19 @@ static void notification_process_notification_message( } } break; + case NotificationMessageTypeLedDisplayBacklightForceOn: + // Force Backlight ON even if its ON now + lcd_backlight_is_on = false; + notification_apply_notification_led_layer( + &app->display, + notification_message->data.led.value * display_brightness_setting * + app->current_night_shift * 1.0f); + reset_mask |= reset_display_mask; + lcd_backlight_is_on = true; + + //start rgb_mod_rainbow_timer when display backlight is ON and all corresponding settings is ON too + rainbow_timer_starter(app); + break; case NotificationMessageTypeLedDisplayBacklightEnforceOn: if(!app->display_led_lock) { app->display_led_lock = true; @@ -740,6 +759,9 @@ static bool notification_load_settings(NotificationApp* app) { storage_file_free(file); furi_record_close(RECORD_STORAGE); + // "kostyl" for update old setting to new without change settings version + if(app->settings.display_off_delay_ms < 2000) app->settings.display_off_delay_ms = 2000; + return fs_result; } @@ -925,6 +947,11 @@ int32_t notification_srv(void* p) { // define rainbow_timer and they callback app->rainbow_timer = furi_timer_alloc(rainbow_timer_callback, FuriTimerTypePeriodic, app); + // define night_shift_demo_timer and they callback. + // used for Setting menu to demonstrate night_shift_backlight when user change value + app->night_shift_demo_timer = + furi_timer_alloc(night_shift_demo_timer_callback, FuriTimerTypeOnce, app); + // if rgb_backlight_installed then start rainbow or set leds colors from saved settings (default index = 0) if(app->settings.rgb.rgb_backlight_installed) { if(app->settings.rgb.rainbow_mode > 0) { diff --git a/applications/services/notification/notification_app.h b/applications/services/notification/notification_app.h index abf3cc15e..111fbd481 100644 --- a/applications/services/notification/notification_app.h +++ b/applications/services/notification/notification_app.h @@ -86,6 +86,7 @@ struct NotificationApp { NotificationSettings settings; FuriTimer* night_shift_timer; + FuriTimer* night_shift_demo_timer; float current_night_shift; FuriTimer* rainbow_timer; diff --git a/applications/services/notification/notification_messages.c b/applications/services/notification/notification_messages.c index 3dc154654..e3f4fbc2c 100644 --- a/applications/services/notification/notification_messages.c +++ b/applications/services/notification/notification_messages.c @@ -17,6 +17,12 @@ const NotificationMessage message_display_backlight_off = { .data.led.value = 0x00, }; +/** Display: backlight wakeup even if its ON now */ +const NotificationMessage message_display_backlight_force_on = { + .type = NotificationMessageTypeLedDisplayBacklightForceOn, + .data.led.value = 0xFF, +}; + /** Display: backlight always on */ const NotificationMessage message_display_backlight_enforce_on = { .type = NotificationMessageTypeLedDisplayBacklightEnforceOn, @@ -259,6 +265,12 @@ const NotificationSequence sequence_display_backlight_off = { NULL, }; +/** Display: backlight wakeup even if its ON now */ +const NotificationSequence sequence_display_backlight_force_on = { + &message_display_backlight_force_on, + NULL, +}; + /** Display: backlight always on lock */ const NotificationSequence sequence_display_backlight_enforce_on = { &message_display_backlight_enforce_on, diff --git a/applications/services/notification/notification_messages.h b/applications/services/notification/notification_messages.h index 3960d93b7..8af499841 100644 --- a/applications/services/notification/notification_messages.h +++ b/applications/services/notification/notification_messages.h @@ -87,7 +87,8 @@ extern const NotificationSequence sequence_display_backlight_on; 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 wakeup even if its ON now */ +extern const NotificationSequence sequence_display_backlight_force_on; /** Display: backlight always on lock */ extern const NotificationSequence sequence_display_backlight_enforce_on; /** Display: backlight always on unlock */ diff --git a/applications/settings/notification_settings/notification_settings_app.c b/applications/settings/notification_settings/notification_settings_app.c index 533db3cd0..e82b02c87 100644 --- a/applications/settings/notification_settings/notification_settings_app.c +++ b/applications/settings/notification_settings/notification_settings_app.c @@ -87,7 +87,7 @@ const float volume_value[VOLUME_COUNT] = { #define DELAY_COUNT 12 const char* const delay_text[DELAY_COUNT] = { "Always ON", - "1s", + "2s", "5s", "10s", "15s", @@ -100,7 +100,7 @@ const char* const delay_text[DELAY_COUNT] = { "30min", }; const uint32_t delay_value[DELAY_COUNT] = - {0, 1000, 5000, 10000, 15000, 30000, 60000, 90000, 120000, 300000, 600000, 1800000}; + {0, 2000, 5000, 10000, 15000, 30000, 60000, 90000, 120000, 300000, 600000, 1800000}; #define VIBRO_COUNT 2 const char* const vibro_text[VIBRO_COUNT] = { @@ -295,7 +295,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_backlight_on); + notification_message(app->notification, &sequence_display_backlight_force_on); } static void screen_changed(VariableItem* item) { @@ -557,11 +557,6 @@ static void night_shift_changed(VariableItem* item) { variable_item_set_current_value_text(item, night_shift_text[index]); app->notification->settings.night_shift = night_shift_value[index]; - app->notification->current_night_shift = night_shift_value[index]; - app->notification->current_night_shift = night_shift_value[index]; - - // force demo night_shift brightness to rgb backlight and stock backlight - notification_message(app->notification, &sequence_display_backlight_on); for(int i = 4; i < 6; i++) { VariableItem* t_item = variable_item_list_get(app->variable_item_list, i); @@ -572,10 +567,22 @@ static void night_shift_changed(VariableItem* item) { } } + // force demo night_shift brightness to rgb backlight and stock backlight for 1,2 sec + // while 1,2 seconds are running, there is another timer "night_shift_timer" can change current_night_shift to day or night value + // so when night_shift_demo_timer ended backlight force ON to day or night brightness + app->notification->current_night_shift = night_shift_value[index]; + notification_message(app->notification, &sequence_display_backlight_force_on); + if(night_shift_value[index] != 1) { night_shift_timer_start(app->notification); + if(furi_timer_is_running(app->notification->night_shift_demo_timer)) { + furi_timer_stop(app->notification->night_shift_demo_timer); + } + furi_timer_start(app->notification->night_shift_demo_timer, furi_ms_to_ticks(1200)); } else { night_shift_timer_stop(app->notification); + if(furi_timer_is_running(app->notification->night_shift_demo_timer)) + furi_timer_stop(app->notification->night_shift_demo_timer); } notification_message_save_settings(app->notification); diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 831932efe..e3159a17e 100755 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,87.5,, +Version,+,87.6,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/applications.h,, Header,+,applications/services/bt/bt_service/bt.h,, @@ -5383,6 +5383,7 @@ Variable,+,sequence_charged,const NotificationSequence, Variable,+,sequence_charging,const NotificationSequence, Variable,+,sequence_display_backlight_enforce_auto,const NotificationSequence, Variable,+,sequence_display_backlight_enforce_on,const NotificationSequence, +Variable,+,sequence_display_backlight_force_on,const NotificationSequence, Variable,+,sequence_display_backlight_off,const NotificationSequence, Variable,+,sequence_display_backlight_off_delay_1000,const NotificationSequence, Variable,+,sequence_display_backlight_on,const NotificationSequence,