mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
Moving RGB backlight back to Notification service finished.
This commit is contained in:
@@ -33,9 +33,11 @@ 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 uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value);
|
||||||
static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app);
|
static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app);
|
||||||
|
|
||||||
|
|
||||||
// --- RGB BACKLIGHT ---
|
// --- RGB BACKLIGHT ---
|
||||||
|
|
||||||
|
// local variable for local use
|
||||||
|
uint8_t rgb_backlight_installed_variable = 0;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* name;
|
char* name;
|
||||||
uint8_t red;
|
uint8_t red;
|
||||||
@@ -75,7 +77,12 @@ const char* rgb_backlight_get_color_text(uint8_t index) {
|
|||||||
return colors[index].name;
|
return colors[index].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use RECORD for acces to rgb service instance and update current colors by static
|
// function for changind local variable from outside;
|
||||||
|
void set_rgb_backlight_installed_variable(uint8_t var) {
|
||||||
|
rgb_backlight_installed_variable = var;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update led current colors by static
|
||||||
void rgb_backlight_set_led_static_color(uint8_t led, uint8_t index) {
|
void rgb_backlight_set_led_static_color(uint8_t led, uint8_t index) {
|
||||||
if(led < SK6805_get_led_count()) {
|
if(led < SK6805_get_led_count()) {
|
||||||
uint8_t r = colors[index].red;
|
uint8_t r = colors[index].red;
|
||||||
@@ -138,11 +145,9 @@ void rgb_backlight_set_led_custom_hsv_color(uint8_t led, uint16_t hue, uint8_t s
|
|||||||
current_led[led].blue = b * 255;
|
current_led[led].blue = b * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use RECORD for acces to rgb service instance, set current_* colors to led and update backlight
|
// set current_* colors to led and update backlight
|
||||||
void rgb_backlight_update(float brightness) {
|
void rgb_backlight_update(float brightness) {
|
||||||
// RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
if(rgb_backlight_installed_variable > 0) {
|
||||||
|
|
||||||
// if(app->settings.rgb.rgb_backlight_installed) {
|
|
||||||
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||||
uint8_t r = current_led[i].red * 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 g = current_led[i].green * brightness * 1.0f;
|
||||||
@@ -150,8 +155,7 @@ void rgb_backlight_update(float brightness) {
|
|||||||
SK6805_set_led_color(i, r, g, b);
|
SK6805_set_led_color(i, r, g, b);
|
||||||
}
|
}
|
||||||
SK6805_update();
|
SK6805_update();
|
||||||
// }
|
}
|
||||||
// furi_record_close(RECORD_RGB_BACKLIGHT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start furi timer for rainbow
|
// start furi timer for rainbow
|
||||||
@@ -213,7 +217,10 @@ static void rainbow_timer_callback(void* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rgb_backlight_set_led_custom_hsv_color(
|
rgb_backlight_set_led_custom_hsv_color(
|
||||||
0, app->rainbow_hue, app->settings.rgb.rainbow_saturation, app->settings.display_brightness);
|
0,
|
||||||
|
app->rainbow_hue,
|
||||||
|
app->settings.rgb.rainbow_saturation,
|
||||||
|
app->settings.display_brightness);
|
||||||
rgb_backlight_set_led_custom_hsv_color(
|
rgb_backlight_set_led_custom_hsv_color(
|
||||||
1, j, app->settings.rgb.rainbow_saturation, app->settings.display_brightness);
|
1, j, app->settings.rgb.rainbow_saturation, app->settings.display_brightness);
|
||||||
rgb_backlight_set_led_custom_hsv_color(
|
rgb_backlight_set_led_custom_hsv_color(
|
||||||
@@ -228,8 +235,7 @@ static void rainbow_timer_callback(void* context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- RGB BACKLIGHT ENF---
|
// --- RGB BACKLIGHT END---
|
||||||
|
|
||||||
|
|
||||||
// --- NIGHT SHIFT ---
|
// --- NIGHT SHIFT ---
|
||||||
|
|
||||||
@@ -815,6 +821,20 @@ static NotificationApp* notification_app_alloc(void) {
|
|||||||
furi_timer_alloc(night_shift_timer_callback, FuriTimerTypePeriodic, app);
|
furi_timer_alloc(night_shift_timer_callback, FuriTimerTypePeriodic, app);
|
||||||
// --- NIGHT SHIFT END ---
|
// --- NIGHT SHIFT END ---
|
||||||
|
|
||||||
|
// init working variables
|
||||||
|
app->rainbow_hue = 1;
|
||||||
|
app->current_night_shift = 1.0f;
|
||||||
|
|
||||||
|
// init rgb.segings values
|
||||||
|
app->settings.rgb.rgb_backlight_installed = 0;
|
||||||
|
app->settings.rgb.led_2_color_index = 0;
|
||||||
|
app->settings.rgb.led_1_color_index = 0;
|
||||||
|
app->settings.rgb.led_0_color_index = 0;
|
||||||
|
app->settings.rgb.rainbow_speed_ms = 100;
|
||||||
|
app->settings.rgb.rainbow_step = 1;
|
||||||
|
app->settings.rgb.rainbow_saturation = 255;
|
||||||
|
app->settings.rgb.rainbow_wide = 50;
|
||||||
|
|
||||||
// use RECORD for setup init values to canvas lcd_inverted
|
// use RECORD for setup init values to canvas lcd_inverted
|
||||||
Gui* tmp_gui = furi_record_open(RECORD_GUI);
|
Gui* tmp_gui = furi_record_open(RECORD_GUI);
|
||||||
Canvas* tmp_canvas = gui_direct_draw_acquire(tmp_gui);
|
Canvas* tmp_canvas = gui_direct_draw_acquire(tmp_gui);
|
||||||
@@ -847,7 +867,7 @@ static void notification_apply_settings(NotificationApp* app) {
|
|||||||
notification_apply_lcd_contrast(app);
|
notification_apply_lcd_contrast(app);
|
||||||
|
|
||||||
// --- NIGHT SHIFT ---
|
// --- NIGHT SHIFT ---
|
||||||
// if night_shift_enabled start timer for controlling current_night_shift multiplicator value depent from current time
|
// if night_shift enabled then start timer for controlling current_night_shift multiplicator value depent from current time
|
||||||
if(app->settings.night_shift != 1) {
|
if(app->settings.night_shift != 1) {
|
||||||
night_shift_timer_start(app);
|
night_shift_timer_start(app);
|
||||||
}
|
}
|
||||||
@@ -878,15 +898,25 @@ int32_t notification_srv(void* p) {
|
|||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
NotificationApp* app = notification_app_alloc();
|
NotificationApp* app = notification_app_alloc();
|
||||||
|
|
||||||
|
notification_init_settings(app);
|
||||||
|
|
||||||
|
notification_vibro_off();
|
||||||
|
notification_sound_off();
|
||||||
|
notification_apply_internal_led_layer(&app->display, 0x00);
|
||||||
|
notification_apply_internal_led_layer(&app->led[0], 0x00);
|
||||||
|
notification_apply_internal_led_layer(&app->led[1], 0x00);
|
||||||
|
notification_apply_internal_led_layer(&app->led[2], 0x00);
|
||||||
|
|
||||||
|
furi_record_create(RECORD_NOTIFICATION, app);
|
||||||
|
|
||||||
// --- RGB BACKLIGHT SECTION ---
|
// --- RGB BACKLIGHT SECTION ---
|
||||||
|
|
||||||
|
//setup local variable
|
||||||
|
set_rgb_backlight_installed_variable(app->settings.rgb.rgb_backlight_installed);
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
// init values
|
|
||||||
app->rainbow_hue = 1;
|
|
||||||
app->current_night_shift = 1.0f;
|
|
||||||
|
|
||||||
// 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) {
|
||||||
@@ -907,17 +937,6 @@ int32_t notification_srv(void* p) {
|
|||||||
|
|
||||||
// --- RGB BACKLIGHT SECTION END ---
|
// --- RGB BACKLIGHT SECTION END ---
|
||||||
|
|
||||||
notification_init_settings(app);
|
|
||||||
|
|
||||||
notification_vibro_off();
|
|
||||||
notification_sound_off();
|
|
||||||
notification_apply_internal_led_layer(&app->display, 0x00);
|
|
||||||
notification_apply_internal_led_layer(&app->led[0], 0x00);
|
|
||||||
notification_apply_internal_led_layer(&app->led[1], 0x00);
|
|
||||||
notification_apply_internal_led_layer(&app->led[2], 0x00);
|
|
||||||
|
|
||||||
furi_record_create(RECORD_NOTIFICATION, app);
|
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ typedef struct {
|
|||||||
Light light;
|
Light light;
|
||||||
} NotificationLedLayer;
|
} NotificationLedLayer;
|
||||||
|
|
||||||
#define NOTIFICATION_SETTINGS_VERSION 0x04
|
#define NOTIFICATION_SETTINGS_VERSION 0x05
|
||||||
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
|
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -101,3 +101,4 @@ void rainbow_timer_stop(NotificationApp* app);
|
|||||||
void rainbow_timer_starter(NotificationApp* app);
|
void rainbow_timer_starter(NotificationApp* app);
|
||||||
const char* rgb_backlight_get_color_text(uint8_t index);
|
const char* rgb_backlight_get_color_text(uint8_t index);
|
||||||
uint8_t rgb_backlight_get_color_count(void);
|
uint8_t rgb_backlight_get_color_count(void);
|
||||||
|
void set_rgb_backlight_installed_variable(uint8_t var);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include <gui/view_dispatcher.h>
|
#include <gui/view_dispatcher.h>
|
||||||
#include <lib/toolbox/value_index.h>
|
#include <lib/toolbox/value_index.h>
|
||||||
|
|
||||||
|
|
||||||
#define MAX_NOTIFICATION_SETTINGS 5
|
#define MAX_NOTIFICATION_SETTINGS 5
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -362,8 +361,8 @@ static void rgb_backlight_installed_changed(VariableItem* item) {
|
|||||||
NotificationAppSettings* app = variable_item_get_context(item);
|
NotificationAppSettings* app = variable_item_get_context(item);
|
||||||
uint8_t index = variable_item_get_current_value_index(item);
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
variable_item_set_current_value_text(item, rgb_backlight_installed_text[index]);
|
variable_item_set_current_value_text(item, rgb_backlight_installed_text[index]);
|
||||||
app->notification->settings.rgb.rgb_backlight_installed =
|
app->notification->settings.rgb.rgb_backlight_installed = rgb_backlight_installed_value[index];
|
||||||
rgb_backlight_installed_value[index];
|
set_rgb_backlight_installed_variable(rgb_backlight_installed_value[index]);
|
||||||
|
|
||||||
// In case of user playing with rgb_backlight_installed swith:
|
// In case of user playing with rgb_backlight_installed swith:
|
||||||
// if user swith_off rgb_backlight_installed (but may be he have mod installed)
|
// if user swith_off rgb_backlight_installed (but may be he have mod installed)
|
||||||
@@ -470,12 +469,9 @@ static void rgb_backlight_rainbow_changed(VariableItem* item) {
|
|||||||
|
|
||||||
// restore saved rgb backlight settings if we switch_off effects
|
// restore saved rgb backlight settings if we switch_off effects
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
rgb_backlight_set_led_static_color(
|
rgb_backlight_set_led_static_color(2, app->notification->settings.rgb.led_2_color_index);
|
||||||
2, app->notification->settings.rgb.led_2_color_index);
|
rgb_backlight_set_led_static_color(1, app->notification->settings.rgb.led_1_color_index);
|
||||||
rgb_backlight_set_led_static_color(
|
rgb_backlight_set_led_static_color(0, app->notification->settings.rgb.led_0_color_index);
|
||||||
1, app->notification->settings.rgb.led_1_color_index);
|
|
||||||
rgb_backlight_set_led_static_color(
|
|
||||||
0, app->notification->settings.rgb.led_0_color_index);
|
|
||||||
rgb_backlight_update(
|
rgb_backlight_update(
|
||||||
app->notification->settings.display_brightness *
|
app->notification->settings.display_brightness *
|
||||||
app->notification->current_night_shift);
|
app->notification->current_night_shift);
|
||||||
@@ -492,8 +488,7 @@ static void rgb_backlight_rainbow_speed_changed(VariableItem* item) {
|
|||||||
uint8_t index = variable_item_get_current_value_index(item);
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
variable_item_set_current_value_text(item, rgb_backlight_rainbow_speed_text[index]);
|
variable_item_set_current_value_text(item, rgb_backlight_rainbow_speed_text[index]);
|
||||||
app->notification->settings.rgb.rainbow_speed_ms =
|
app->notification->settings.rgb.rainbow_speed_ms = rgb_backlight_rainbow_speed_value[index];
|
||||||
rgb_backlight_rainbow_speed_value[index];
|
|
||||||
|
|
||||||
// save settings and restart timer with new speed value
|
// save settings and restart timer with new speed value
|
||||||
rainbow_timer_starter(app->notification);
|
rainbow_timer_starter(app->notification);
|
||||||
|
|||||||
Reference in New Issue
Block a user