mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
Rework night shift setting demo
This commit is contained in:
@@ -248,7 +248,7 @@ void night_shift_timer_start(NotificationApp* app) {
|
|||||||
if(furi_timer_is_running(app->night_shift_timer)) {
|
if(furi_timer_is_running(app->night_shift_timer)) {
|
||||||
furi_timer_stop(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 ---
|
// --- NIGHT SHIFT END ---
|
||||||
|
|
||||||
void notification_message_save_settings(NotificationApp * app) {
|
void notification_message_save_settings(NotificationApp * app) {
|
||||||
@@ -289,8 +295,8 @@ void notification_message_save_settings(NotificationApp* app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// internal layer
|
// internal layer
|
||||||
static void
|
static void notification_apply_internal_led_layer(
|
||||||
notification_apply_internal_led_layer(NotificationLedLayer* layer, uint8_t layer_value) {
|
NotificationLedLayer * layer, uint8_t layer_value) {
|
||||||
furi_assert(layer);
|
furi_assert(layer);
|
||||||
furi_assert(layer->index < LayerMAX);
|
furi_assert(layer->index < LayerMAX);
|
||||||
|
|
||||||
@@ -325,8 +331,7 @@ static bool notification_is_any_led_layer_internal_and_not_empty(NotificationApp
|
|||||||
|
|
||||||
// notification layer
|
// notification layer
|
||||||
static void notification_apply_notification_led_layer(
|
static void notification_apply_notification_led_layer(
|
||||||
NotificationLedLayer* layer,
|
NotificationLedLayer * layer, const uint8_t layer_value) {
|
||||||
const uint8_t layer_value) {
|
|
||||||
furi_assert(layer);
|
furi_assert(layer);
|
||||||
furi_assert(layer->index < LayerMAX);
|
furi_assert(layer->index < LayerMAX);
|
||||||
|
|
||||||
@@ -357,9 +362,7 @@ static void notification_reset_notification_led_layer(NotificationLedLayer* laye
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void notification_reset_notification_layer(
|
static void notification_reset_notification_layer(
|
||||||
NotificationApp* app,
|
NotificationApp * app, uint8_t reset_mask, float display_brightness_set) {
|
||||||
uint8_t reset_mask,
|
|
||||||
float display_brightness_set) {
|
|
||||||
if(reset_mask & reset_blink_mask) {
|
if(reset_mask & reset_blink_mask) {
|
||||||
furi_hal_light_blink_stop();
|
furi_hal_light_blink_stop();
|
||||||
}
|
}
|
||||||
@@ -391,7 +394,8 @@ static void notification_reset_notification_layer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void notification_apply_notification_leds(NotificationApp* app, const uint8_t* values) {
|
static void notification_apply_notification_leds(
|
||||||
|
NotificationApp * app, const uint8_t* values) {
|
||||||
for(uint8_t i = 0; i < NOTIFICATION_LED_COUNT; i++) {
|
for(uint8_t i = 0; i < NOTIFICATION_LED_COUNT; i++) {
|
||||||
notification_apply_notification_led_layer(
|
notification_apply_notification_led_layer(
|
||||||
&app->led[i], notification_settings_get_rgb_led_brightness(app, values[i]));
|
&app->led[i], notification_settings_get_rgb_led_brightness(app, values[i]));
|
||||||
@@ -403,7 +407,8 @@ uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8
|
|||||||
return value * app->settings.display_brightness;
|
return value * app->settings.display_brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value) {
|
static uint8_t notification_settings_get_rgb_led_brightness(
|
||||||
|
NotificationApp * app, uint8_t value) {
|
||||||
return value * app->settings.led_brightness;
|
return value * app->settings.led_brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,8 +452,7 @@ static void notification_display_timer(void* ctx) {
|
|||||||
|
|
||||||
// message processing
|
// message processing
|
||||||
static void notification_process_notification_message(
|
static void notification_process_notification_message(
|
||||||
NotificationApp* app,
|
NotificationApp * app, NotificationAppMessage * message) {
|
||||||
NotificationAppMessage* message) {
|
|
||||||
uint32_t notification_message_index = 0;
|
uint32_t notification_message_index = 0;
|
||||||
bool force_volume = false;
|
bool force_volume = false;
|
||||||
bool force_vibro = false;
|
bool force_vibro = false;
|
||||||
@@ -669,8 +673,8 @@ static void notification_process_notification_message(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void notification_process_internal_message(
|
||||||
notification_process_internal_message(NotificationApp* app, NotificationAppMessage* message) {
|
NotificationApp * app, NotificationAppMessage * message) {
|
||||||
uint32_t notification_message_index = 0;
|
uint32_t notification_message_index = 0;
|
||||||
const NotificationMessage* notification_message;
|
const NotificationMessage* notification_message;
|
||||||
notification_message = (*message->sequence)[notification_message_index];
|
notification_message = (*message->sequence)[notification_message_index];
|
||||||
@@ -739,7 +743,10 @@ static bool notification_load_settings(NotificationApp* app) {
|
|||||||
if(fs_result) {
|
if(fs_result) {
|
||||||
if(settings.version != NOTIFICATION_SETTINGS_VERSION) {
|
if(settings.version != NOTIFICATION_SETTINGS_VERSION) {
|
||||||
FURI_LOG_E(
|
FURI_LOG_E(
|
||||||
TAG, "version(%d != %d) mismatch", settings.version, NOTIFICATION_SETTINGS_VERSION);
|
TAG,
|
||||||
|
"version(%d != %d) mismatch",
|
||||||
|
settings.version,
|
||||||
|
NOTIFICATION_SETTINGS_VERSION);
|
||||||
} else {
|
} else {
|
||||||
furi_kernel_lock();
|
furi_kernel_lock();
|
||||||
memcpy(&app->settings, &settings, settings_size);
|
memcpy(&app->settings, &settings, settings_size);
|
||||||
@@ -938,6 +945,11 @@ int32_t notification_srv(void* p) {
|
|||||||
// define rainbow_timer and they callback
|
// define rainbow_timer and they callback
|
||||||
app->rainbow_timer = furi_timer_alloc(rainbow_timer_callback, FuriTimerTypePeriodic, app);
|
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 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.rgb_backlight_installed) {
|
||||||
if(app->settings.rgb.rainbow_mode > 0) {
|
if(app->settings.rgb.rainbow_mode > 0) {
|
||||||
@@ -960,7 +972,8 @@ int32_t notification_srv(void* p) {
|
|||||||
|
|
||||||
NotificationAppMessage message;
|
NotificationAppMessage message;
|
||||||
while(1) {
|
while(1) {
|
||||||
furi_check(furi_message_queue_get(app->queue, &message, FuriWaitForever) == FuriStatusOk);
|
furi_check(
|
||||||
|
furi_message_queue_get(app->queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||||
|
|
||||||
switch(message.type) {
|
switch(message.type) {
|
||||||
case NotificationLayerMessage:
|
case NotificationLayerMessage:
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ struct NotificationApp {
|
|||||||
NotificationSettings settings;
|
NotificationSettings settings;
|
||||||
|
|
||||||
FuriTimer* night_shift_timer;
|
FuriTimer* night_shift_timer;
|
||||||
|
FuriTimer* night_shift_demo_timer;
|
||||||
float current_night_shift;
|
float current_night_shift;
|
||||||
|
|
||||||
FuriTimer* rainbow_timer;
|
FuriTimer* rainbow_timer;
|
||||||
|
|||||||
@@ -558,10 +558,6 @@ static void night_shift_changed(VariableItem* item) {
|
|||||||
variable_item_set_current_value_text(item, night_shift_text[index]);
|
variable_item_set_current_value_text(item, night_shift_text[index]);
|
||||||
app->notification->settings.night_shift = night_shift_value[index];
|
app->notification->settings.night_shift = night_shift_value[index];
|
||||||
|
|
||||||
// force demo night_shift brightness to rgb backlight and stock backlight
|
|
||||||
// app->notification->current_night_shift = night_shift_value[index];
|
|
||||||
// notification_message(app->notification, &sequence_display_backlight_force_on);
|
|
||||||
|
|
||||||
for(int i = 4; i < 6; i++) {
|
for(int i = 4; i < 6; i++) {
|
||||||
VariableItem* t_item = variable_item_list_get(app->variable_item_list, i);
|
VariableItem* t_item = variable_item_list_get(app->variable_item_list, i);
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
@@ -571,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) {
|
if(night_shift_value[index] != 1) {
|
||||||
night_shift_timer_start(app->notification);
|
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 {
|
} else {
|
||||||
night_shift_timer_stop(app->notification);
|
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);
|
notification_message_save_settings(app->notification);
|
||||||
|
|||||||
Reference in New Issue
Block a user