mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
Merge pull request #885 from Dmitry422/dev
Night Shift Feature (dimming backlight in selected time interval)
This commit is contained in:
@@ -33,6 +33,53 @@ static uint8_t notification_settings_get_display_brightness(NotificationApp* app
|
||||
static uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value);
|
||||
static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app);
|
||||
|
||||
// --- NIGHT SHIFT ---
|
||||
|
||||
void night_shift_timer_start(NotificationApp* app) {
|
||||
if(app->settings.night_shift != 1) {
|
||||
furi_timer_start(app->night_shift_timer, furi_ms_to_ticks(2000));
|
||||
}
|
||||
}
|
||||
|
||||
void night_shift_timer_stop(NotificationApp* app) {
|
||||
if(furi_timer_is_running(app->night_shift_timer)) {
|
||||
furi_timer_stop(app->night_shift_timer);
|
||||
}
|
||||
}
|
||||
|
||||
// every callback time we check current time and current night_shift_settings value
|
||||
void night_shift_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
NotificationApp* app = context;
|
||||
DateTime current_date_time;
|
||||
|
||||
// IN DEVELOPMENT
|
||||
// // save current night_shift;
|
||||
// float old_night_shift = app->current_night_shift;
|
||||
|
||||
// take system time and convert to minutes
|
||||
furi_hal_rtc_get_datetime(¤t_date_time);
|
||||
uint32_t time = current_date_time.hour * 60 + current_date_time.minute;
|
||||
|
||||
// if current time not in night_shift range then current_night_shift = 1 else = settings value;
|
||||
// set values to stock and rgb backlights
|
||||
if((time > app->settings.night_shift_end) && (time < app->settings.night_shift_start)) {
|
||||
app->current_night_shift = 1.0f;
|
||||
app->rgb_srv->current_night_shift = 1.0f;
|
||||
} else {
|
||||
app->current_night_shift = app->settings.night_shift;
|
||||
app->rgb_srv->current_night_shift = app->settings.night_shift;
|
||||
}
|
||||
|
||||
// IN DEVELOPMENT
|
||||
// // if night shift was changed then update stock and rgb backlight to new value
|
||||
// if(old_night_shift != app->current_night_shift) {
|
||||
// notification_message(app, &sequence_display_backlight_on);
|
||||
// }
|
||||
}
|
||||
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
void notification_message_save_settings(NotificationApp* app) {
|
||||
NotificationAppMessage m = {
|
||||
.type = SaveSettingsMessage, .back_event = furi_event_flag_alloc()};
|
||||
@@ -129,7 +176,11 @@ static void notification_reset_notification_layer(
|
||||
}
|
||||
if(reset_mask & reset_display_mask) {
|
||||
if(!float_is_equal(display_brightness_set, app->settings.display_brightness)) {
|
||||
furi_hal_light_set(LightBacklight, app->settings.display_brightness * 0xFF);
|
||||
// --- NIGHT SHIFT ---
|
||||
furi_hal_light_set(
|
||||
LightBacklight,
|
||||
app->settings.display_brightness * 0xFF * app->current_night_shift * 1.0f);
|
||||
// --- NIGHT SHIFT END---
|
||||
}
|
||||
furi_timer_start(app->display_timer, notification_settings_display_off_delay_ticks(app));
|
||||
}
|
||||
@@ -214,15 +265,17 @@ static void notification_process_notification_message(
|
||||
// if on - switch on and start timer
|
||||
// if off - switch off and stop timer
|
||||
// on timer - switch off
|
||||
// --- NIGHT SHIFT ---
|
||||
if(notification_message->data.led.value > 0x00) {
|
||||
notification_apply_notification_led_layer(
|
||||
&app->display,
|
||||
notification_message->data.led.value * display_brightness_setting);
|
||||
notification_message->data.led.value * display_brightness_setting *
|
||||
app->current_night_shift * 1.0f);
|
||||
reset_mask |= reset_display_mask;
|
||||
|
||||
//start rgb_mod_rainbow_timer when display backlight is ON and all corresponding settings is ON too
|
||||
rainbow_timer_starter(app->rgb_srv);
|
||||
|
||||
// --- NIGHT SHIFT END ---
|
||||
} else {
|
||||
reset_mask &= ~reset_display_mask;
|
||||
notification_reset_notification_led_layer(&app->display);
|
||||
@@ -238,10 +291,12 @@ static void notification_process_notification_message(
|
||||
case NotificationMessageTypeLedDisplayBacklightEnforceOn:
|
||||
furi_check(app->display_led_lock < UINT8_MAX);
|
||||
app->display_led_lock++;
|
||||
// --- NIGHT SHIFT ---
|
||||
if(app->display_led_lock == 1) {
|
||||
notification_apply_internal_led_layer(
|
||||
&app->display,
|
||||
notification_message->data.led.value * display_brightness_setting);
|
||||
notification_message->data.led.value * display_brightness_setting *
|
||||
app->current_night_shift * 1.0f);
|
||||
}
|
||||
break;
|
||||
case NotificationMessageTypeLedDisplayBacklightEnforceAuto:
|
||||
@@ -250,8 +305,10 @@ static void notification_process_notification_message(
|
||||
if(app->display_led_lock == 0) {
|
||||
notification_apply_internal_led_layer(
|
||||
&app->display,
|
||||
notification_message->data.led.value * display_brightness_setting);
|
||||
notification_message->data.led.value * display_brightness_setting *
|
||||
app->current_night_shift * 1.0f);
|
||||
}
|
||||
// --- NIGHT SHIFT END ---
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Incorrect BacklightEnforce use");
|
||||
}
|
||||
@@ -559,6 +616,17 @@ static NotificationApp* notification_app_alloc(void) {
|
||||
furi_pubsub_subscribe(app->event_record, input_event_callback, app);
|
||||
notification_message(app, &sequence_display_backlight_on);
|
||||
|
||||
// --- NIGHT SHIFT ---
|
||||
app->rgb_srv = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
app->rgb_srv->current_night_shift = 1.0f;
|
||||
app->current_night_shift = 1.0f;
|
||||
app->settings.night_shift = 1.0f;
|
||||
app->settings.night_shift_start = 1020;
|
||||
app->settings.night_shift_end = 300;
|
||||
app->night_shift_timer =
|
||||
furi_timer_alloc(night_shift_timer_callback, FuriTimerTypePeriodic, app);
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -582,6 +650,13 @@ static void notification_apply_settings(NotificationApp* app) {
|
||||
}
|
||||
|
||||
notification_apply_lcd_contrast(app);
|
||||
|
||||
// --- NIGHT SHIFT ---
|
||||
// if night_shift_enabled start timer for controlling current_night_shift multiplicator value depent from current time
|
||||
if(app->settings.night_shift != 1) {
|
||||
night_shift_timer_start(app);
|
||||
}
|
||||
// --- NIGHT SHIFT END ---
|
||||
}
|
||||
|
||||
static void notification_init_settings(NotificationApp* app) {
|
||||
@@ -600,7 +675,7 @@ static void notification_init_settings(NotificationApp* app) {
|
||||
int32_t notification_srv(void* p) {
|
||||
UNUSED(p);
|
||||
NotificationApp* app = notification_app_alloc();
|
||||
app->rgb_srv = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
|
||||
notification_init_settings(app);
|
||||
|
||||
notification_vibro_off();
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef struct {
|
||||
Light light;
|
||||
} NotificationLedLayer;
|
||||
|
||||
#define NOTIFICATION_SETTINGS_VERSION 0x02
|
||||
#define NOTIFICATION_SETTINGS_VERSION 0x03
|
||||
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
|
||||
|
||||
typedef struct {
|
||||
@@ -45,6 +45,9 @@ typedef struct {
|
||||
uint32_t display_off_delay_ms;
|
||||
int8_t contrast;
|
||||
bool vibro_on;
|
||||
float night_shift;
|
||||
uint32_t night_shift_start;
|
||||
uint32_t night_shift_end;
|
||||
} NotificationSettings;
|
||||
|
||||
struct NotificationApp {
|
||||
@@ -58,6 +61,11 @@ struct NotificationApp {
|
||||
|
||||
NotificationSettings settings;
|
||||
RGBBacklightApp* rgb_srv;
|
||||
|
||||
FuriTimer* night_shift_timer;
|
||||
float current_night_shift;
|
||||
};
|
||||
|
||||
void notification_message_save_settings(NotificationApp* app);
|
||||
void night_shift_timer_start(NotificationApp* app);
|
||||
void night_shift_timer_stop(NotificationApp* app);
|
||||
|
||||
@@ -137,9 +137,9 @@ void rgb_backlight_update(float brightness) {
|
||||
|
||||
if(app->settings->rgb_backlight_installed) {
|
||||
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
uint8_t r = current_led[i].red * (brightness * 1.0f);
|
||||
uint8_t g = current_led[i].green * (brightness * 1.0f);
|
||||
uint8_t b = current_led[i].blue * (brightness * 1.0f);
|
||||
uint8_t r = current_led[i].red * brightness * 1.0f;
|
||||
uint8_t g = current_led[i].green * brightness * 1.0f;
|
||||
uint8_t b = current_led[i].blue * brightness * 1.0f;
|
||||
SK6805_set_led_color(i, r, g, b);
|
||||
}
|
||||
SK6805_update();
|
||||
@@ -154,7 +154,9 @@ void rainbow_timer_start(RGBBacklightApp* app) {
|
||||
|
||||
// stop furi timer for rainbow
|
||||
void rainbow_timer_stop(RGBBacklightApp* app) {
|
||||
furi_timer_stop(app->rainbow_timer);
|
||||
if(furi_timer_is_running(app->rainbow_timer)) {
|
||||
furi_timer_stop(app->rainbow_timer);
|
||||
}
|
||||
}
|
||||
|
||||
// if rgb_backlight_installed then apply rainbow colors to backlight and start/restart/stop rainbow_timer
|
||||
@@ -212,7 +214,7 @@ static void rainbow_timer_callback(void* context) {
|
||||
break;
|
||||
}
|
||||
|
||||
rgb_backlight_update(app->settings->brightness);
|
||||
rgb_backlight_update(app->settings->brightness * app->current_night_shift);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,6 +233,7 @@ int32_t rgb_backlight_srv(void* p) {
|
||||
rgb_backlight_settings_load(app->settings);
|
||||
|
||||
app->rainbow_hue = 1;
|
||||
app->current_night_shift = 1.0f;
|
||||
|
||||
furi_record_create(RECORD_RGB_BACKLIGHT, app);
|
||||
|
||||
@@ -242,7 +245,7 @@ int32_t rgb_backlight_srv(void* p) {
|
||||
rgb_backlight_set_led_static_color(2, app->settings->led_2_color_index);
|
||||
rgb_backlight_set_led_static_color(1, app->settings->led_1_color_index);
|
||||
rgb_backlight_set_led_static_color(0, app->settings->led_0_color_index);
|
||||
rgb_backlight_update(app->settings->brightness);
|
||||
rgb_backlight_update(app->settings->brightness * app->current_night_shift);
|
||||
}
|
||||
// if rgb_backlight not installed then set default static orange color(index=0) to all leds (0-2) and force light on
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,9 @@ typedef struct {
|
||||
uint8_t rainbow_green;
|
||||
uint8_t rainbow_blue;
|
||||
RGBBacklightSettings* settings;
|
||||
// night_shift multiplicator for leds brightnes coming from Notificatoin app.
|
||||
float current_night_shift;
|
||||
|
||||
} RGBBacklightApp;
|
||||
|
||||
#define RECORD_RGB_BACKLIGHT "rgb_backlight"
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#define RGB_BACKLIGHT_SETTINGS_PATH INT_PATH(RGB_BACKLIGHT_SETTINGS_FILE_NAME)
|
||||
|
||||
#define RGB_BACKLIGHT_SETTINGS_MAGIC (0x30)
|
||||
#define RGB_BACKLIGHT_SETTINGS_VER_PREV (2) // Previous version number
|
||||
#define RGB_BACKLIGHT_SETTINGS_VER (3) // Current version number
|
||||
#define RGB_BACKLIGHT_SETTINGS_VER_PREV (4) // Previous version number
|
||||
#define RGB_BACKLIGHT_SETTINGS_VER (5) // Current version number
|
||||
|
||||
//pervious settings must be copyed from previous rgb_backlight_settings.h file
|
||||
typedef struct {
|
||||
@@ -30,6 +30,7 @@ typedef struct {
|
||||
uint16_t rainbow_step;
|
||||
uint8_t rainbow_saturation;
|
||||
uint8_t rainbow_wide;
|
||||
|
||||
} RGBBacklightSettingsPrevious;
|
||||
|
||||
void rgb_backlight_settings_load(RGBBacklightSettings* settings) {
|
||||
|
||||
@@ -182,6 +182,94 @@ typedef enum {
|
||||
|
||||
// --- RGB BACKLIGHT END ---
|
||||
|
||||
// --- NIGHT SHIFT ---
|
||||
#define NIGHT_SHIFT_COUNT 7
|
||||
const char* const night_shift_text[NIGHT_SHIFT_COUNT] =
|
||||
{"OFF", "-10%", "-20%", "-30%", "-40%", "-50%", "-60%"
|
||||
|
||||
};
|
||||
const float night_shift_value[NIGHT_SHIFT_COUNT] = {
|
||||
1.0f,
|
||||
0.9f,
|
||||
0.8f,
|
||||
0.7f,
|
||||
0.6f,
|
||||
0.5f,
|
||||
0.4f,
|
||||
};
|
||||
|
||||
#define NIGHT_SHIFT_START_COUNT 14
|
||||
const char* const night_shift_start_text[NIGHT_SHIFT_START_COUNT] = {
|
||||
"17:00",
|
||||
"17:30",
|
||||
"18:00",
|
||||
"18:30",
|
||||
"19:00",
|
||||
"19:30",
|
||||
"20:00",
|
||||
"20:30",
|
||||
"21:00",
|
||||
"21:30",
|
||||
"22:00",
|
||||
"22:30",
|
||||
"23:00",
|
||||
"23:30",
|
||||
};
|
||||
// values in minutes like 23:30 = 23*60+30=1410
|
||||
const uint32_t night_shift_start_value[NIGHT_SHIFT_START_COUNT] = {
|
||||
1020,
|
||||
1050,
|
||||
1080,
|
||||
1110,
|
||||
1140,
|
||||
1170,
|
||||
1200,
|
||||
1230,
|
||||
1260,
|
||||
1290,
|
||||
1320,
|
||||
1350,
|
||||
1380,
|
||||
1410,
|
||||
};
|
||||
|
||||
#define NIGHT_SHIFT_END_COUNT 14
|
||||
const char* const night_shift_end_text[NIGHT_SHIFT_END_COUNT] = {
|
||||
"05:00",
|
||||
"05:30",
|
||||
"06:00",
|
||||
"06:30",
|
||||
"07:00",
|
||||
"07:30",
|
||||
"08:00",
|
||||
"08:30",
|
||||
"09:00",
|
||||
"09:30",
|
||||
"10:00",
|
||||
"10:30",
|
||||
"11:00",
|
||||
"11:30",
|
||||
};
|
||||
// values in minutes like 6:30 = 6*60+30=390
|
||||
const uint32_t night_shift_end_value[NIGHT_SHIFT_END_COUNT] = {
|
||||
300,
|
||||
330,
|
||||
360,
|
||||
390,
|
||||
410,
|
||||
440,
|
||||
470,
|
||||
500,
|
||||
530,
|
||||
560,
|
||||
590,
|
||||
620,
|
||||
650,
|
||||
680,
|
||||
};
|
||||
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
static void contrast_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
@@ -261,16 +349,19 @@ static void rgb_backlight_installed_changed(VariableItem* item) {
|
||||
variable_item_set_current_value_text(item, rgb_backlight_installed_text[index]);
|
||||
app->notification->rgb_srv->settings->rgb_backlight_installed =
|
||||
rgb_backlight_installed_value[index];
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
|
||||
app->notification->rgb_srv->settings->brightness =
|
||||
app->notification->settings.display_brightness;
|
||||
|
||||
// In case of user playing with rgb_backlight_installed swith:
|
||||
// if user swith_off rgb_backlight_installed (but may be he have mod installed)
|
||||
// then force set default orange color - defence from stupid.
|
||||
// then force set default orange color and stop rainbow timer
|
||||
if(index == 0) {
|
||||
rgb_backlight_set_led_static_color(2, 0);
|
||||
rgb_backlight_set_led_static_color(1, 0);
|
||||
rgb_backlight_set_led_static_color(0, 0);
|
||||
SK6805_update();
|
||||
rainbow_timer_stop(app->notification->rgb_srv);
|
||||
// start rainbow (if its Enabled) or set saved static colors if user swith_on rgb_backlight_installed switch
|
||||
} else {
|
||||
if(app->notification->rgb_srv->settings->rainbow_mode > 0) {
|
||||
@@ -282,7 +373,9 @@ static void rgb_backlight_installed_changed(VariableItem* item) {
|
||||
1, app->notification->rgb_srv->settings->led_1_color_index);
|
||||
rgb_backlight_set_led_static_color(
|
||||
0, app->notification->rgb_srv->settings->led_0_color_index);
|
||||
rgb_backlight_update(app->notification->settings.display_brightness);
|
||||
rgb_backlight_update(
|
||||
app->notification->settings.display_brightness *
|
||||
app->notification->current_night_shift);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,6 +392,8 @@ static void rgb_backlight_installed_changed(VariableItem* item) {
|
||||
variable_item_set_locked(t_item, false, "RGB\nOFF!");
|
||||
}
|
||||
}
|
||||
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
static void led_2_color_changed(VariableItem* item) {
|
||||
@@ -311,8 +406,11 @@ static void led_2_color_changed(VariableItem* item) {
|
||||
// dont update screen color if rainbow timer working
|
||||
if(!furi_timer_is_running(app->notification->rgb_srv->rainbow_timer)) {
|
||||
rgb_backlight_set_led_static_color(2, index);
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
rgb_backlight_update(
|
||||
app->notification->rgb_srv->settings->brightness *
|
||||
app->notification->current_night_shift);
|
||||
}
|
||||
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
@@ -326,7 +424,9 @@ static void led_1_color_changed(VariableItem* item) {
|
||||
// dont update screen color if rainbow timer working
|
||||
if(!furi_timer_is_running(app->notification->rgb_srv->rainbow_timer)) {
|
||||
rgb_backlight_set_led_static_color(1, index);
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
rgb_backlight_update(
|
||||
app->notification->rgb_srv->settings->brightness *
|
||||
app->notification->current_night_shift);
|
||||
}
|
||||
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
@@ -342,7 +442,9 @@ static void led_0_color_changed(VariableItem* item) {
|
||||
// dont update screen color if rainbow timer working
|
||||
if(!furi_timer_is_running(app->notification->rgb_srv->rainbow_timer)) {
|
||||
rgb_backlight_set_led_static_color(0, index);
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
rgb_backlight_update(
|
||||
app->notification->rgb_srv->settings->brightness *
|
||||
app->notification->current_night_shift);
|
||||
}
|
||||
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
@@ -355,19 +457,23 @@ static void rgb_backlight_rainbow_changed(VariableItem* item) {
|
||||
variable_item_set_current_value_text(item, rgb_backlight_rainbow_mode_text[index]);
|
||||
app->notification->rgb_srv->settings->rainbow_mode = rgb_backlight_rainbow_mode_value[index];
|
||||
|
||||
rainbow_timer_starter(app->notification->rgb_srv);
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
|
||||
// restore saved rgb backlight settings if we switch_off rainbow mode
|
||||
if(app->notification->rgb_srv->settings->rainbow_mode == 0) {
|
||||
// restore saved rgb backlight settings if we switch_off effects
|
||||
if(index == 0) {
|
||||
rgb_backlight_set_led_static_color(
|
||||
2, app->notification->rgb_srv->settings->led_2_color_index);
|
||||
rgb_backlight_set_led_static_color(
|
||||
1, app->notification->rgb_srv->settings->led_1_color_index);
|
||||
rgb_backlight_set_led_static_color(
|
||||
0, app->notification->rgb_srv->settings->led_0_color_index);
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
rgb_backlight_update(
|
||||
app->notification->rgb_srv->settings->brightness *
|
||||
app->notification->current_night_shift);
|
||||
rainbow_timer_stop(app->notification->rgb_srv);
|
||||
} else {
|
||||
rainbow_timer_starter(app->notification->rgb_srv);
|
||||
}
|
||||
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
static void rgb_backlight_rainbow_speed_changed(VariableItem* item) {
|
||||
@@ -379,8 +485,8 @@ static void rgb_backlight_rainbow_speed_changed(VariableItem* item) {
|
||||
rgb_backlight_rainbow_speed_value[index];
|
||||
|
||||
// save settings and restart timer with new speed value
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
rainbow_timer_starter(app->notification->rgb_srv);
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
static void rgb_backlight_rainbow_step_changed(VariableItem* item) {
|
||||
@@ -402,6 +508,7 @@ static void rgb_backlight_rainbow_saturation_changed(VariableItem* item) {
|
||||
snprintf(valtext, sizeof(valtext), "%d", index);
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
app->notification->rgb_srv->settings->rainbow_saturation = index;
|
||||
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
@@ -412,9 +519,7 @@ static void rgb_backlight_rainbow_wide_changed(VariableItem* item) {
|
||||
variable_item_set_current_value_text(item, rgb_backlight_rainbow_wide_text[index]);
|
||||
app->notification->rgb_srv->settings->rainbow_wide = rgb_backlight_rainbow_wide_value[index];
|
||||
|
||||
// save settings and restart timer with new speed value
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
rainbow_timer_starter(app->notification->rgb_srv);
|
||||
}
|
||||
|
||||
// open rgb_settings_view if user press OK on first (index=0) menu string and (debug mode or rgb_backlight_installed is true)
|
||||
@@ -436,6 +541,65 @@ static uint32_t notification_app_rgb_settings_exit(void* context) {
|
||||
}
|
||||
//--- RGB BACKLIGHT END ---
|
||||
|
||||
// --- NIGHT SHIFT ---
|
||||
|
||||
static void night_shift_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(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->rgb_srv->current_night_shift = night_shift_value[index];
|
||||
|
||||
// force demo night_shift brightness ot rgb backlight and stock backlight
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
|
||||
int slide = 0;
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) ||
|
||||
(app->notification->rgb_srv->settings->rgb_backlight_installed)) {
|
||||
slide = 1;
|
||||
}
|
||||
for(int i = 4 + slide; i < (6 + slide); i++) {
|
||||
VariableItem* t_item = variable_item_list_get(app->variable_item_list, i);
|
||||
if(index == 0) {
|
||||
variable_item_set_locked(t_item, true, "Night shift\nOFF!");
|
||||
} else {
|
||||
variable_item_set_locked(t_item, false, "Night shift\nOFF!");
|
||||
}
|
||||
}
|
||||
|
||||
if(night_shift_value[index] != 1) {
|
||||
night_shift_timer_start(app->notification);
|
||||
} else {
|
||||
night_shift_timer_stop(app->notification);
|
||||
}
|
||||
|
||||
notification_message_save_settings(app->notification);
|
||||
}
|
||||
|
||||
static void night_shift_start_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, night_shift_start_text[index]);
|
||||
app->notification->settings.night_shift_start = night_shift_start_value[index];
|
||||
|
||||
notification_message_save_settings(app->notification);
|
||||
}
|
||||
|
||||
static void night_shift_end_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, night_shift_end_text[index]);
|
||||
app->notification->settings.night_shift_end = night_shift_end_value[index];
|
||||
|
||||
notification_message_save_settings(app->notification);
|
||||
}
|
||||
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
static uint32_t notification_app_settings_exit(void* context) {
|
||||
UNUSED(context);
|
||||
return VIEW_NONE;
|
||||
@@ -488,6 +652,40 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, delay_text[value_index]);
|
||||
|
||||
// --- NIGHT SHIFT ---
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list, "Night shift", NIGHT_SHIFT_COUNT, night_shift_changed, app);
|
||||
value_index = value_index_float(
|
||||
app->notification->settings.night_shift, night_shift_value, NIGHT_SHIFT_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, night_shift_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list,
|
||||
" . Start",
|
||||
NIGHT_SHIFT_START_COUNT,
|
||||
night_shift_start_changed,
|
||||
app);
|
||||
value_index = value_index_uint32(
|
||||
app->notification->settings.night_shift_start,
|
||||
night_shift_start_value,
|
||||
NIGHT_SHIFT_START_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, night_shift_start_text[value_index]);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->settings.night_shift == 1), "Night shift \nOFF!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list, " . End", NIGHT_SHIFT_END_COUNT, night_shift_end_changed, app);
|
||||
value_index = value_index_uint32(
|
||||
app->notification->settings.night_shift_end, night_shift_end_value, NIGHT_SHIFT_END_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, night_shift_end_text[value_index]);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->settings.night_shift == 1), "Night shift \nOFF!");
|
||||
|
||||
// --- NIGHT SHIFT END---
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list, "LED Brightness", BACKLIGHT_COUNT, led_changed, app);
|
||||
value_index = value_index_float(
|
||||
@@ -551,7 +749,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
// led_1 color
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"LED 1 Color",
|
||||
"Led 1 Color",
|
||||
rgb_backlight_get_color_count(),
|
||||
led_2_color_changed,
|
||||
app);
|
||||
@@ -566,7 +764,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
// led_2 color
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"LED 2 Color",
|
||||
"Led 2 Color",
|
||||
rgb_backlight_get_color_count(),
|
||||
led_1_color_changed,
|
||||
app);
|
||||
@@ -581,7 +779,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
// led 3 color
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"LED 3 Color",
|
||||
"Led 3 Color",
|
||||
rgb_backlight_get_color_count(),
|
||||
led_0_color_changed,
|
||||
app);
|
||||
@@ -593,10 +791,10 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||
"RGB MOD \nOFF!");
|
||||
|
||||
// Rainbow mode
|
||||
// Efects
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"Rainbow mode",
|
||||
"Effects",
|
||||
RGB_BACKLIGHT_RAINBOW_MODE_COUNT,
|
||||
rgb_backlight_rainbow_changed,
|
||||
app);
|
||||
@@ -613,7 +811,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"Rainbow speed",
|
||||
" . Speed",
|
||||
RGB_BACKLIGHT_RAINBOW_SPEED_COUNT,
|
||||
rgb_backlight_rainbow_speed_changed,
|
||||
app);
|
||||
@@ -630,7 +828,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"Rainbow step",
|
||||
" . Color step",
|
||||
RGB_BACKLIGHT_RAINBOW_STEP_COUNT,
|
||||
rgb_backlight_rainbow_step_changed,
|
||||
app);
|
||||
@@ -647,7 +845,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"Saturation",
|
||||
" . Saturation",
|
||||
255,
|
||||
rgb_backlight_rainbow_saturation_changed,
|
||||
app);
|
||||
@@ -663,7 +861,7 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"Wave wide",
|
||||
" . Wave wide",
|
||||
RGB_BACKLIGHT_RAINBOW_WIDE_COUNT,
|
||||
rgb_backlight_rainbow_wide_changed,
|
||||
app);
|
||||
|
||||
Reference in New Issue
Block a user