mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
still fucking ))
This commit is contained in:
@@ -748,9 +748,9 @@ int32_t notification_srv(void* p) {
|
||||
notification_process_internal_message(app, &message);
|
||||
break;
|
||||
case SaveSettingsMessage:
|
||||
//call rgb_mod_timer_control (start or stop) when we save settings
|
||||
rainbow_timer_starter(app->rgb_srv);
|
||||
rgb_backlight_settings_save(app->rgb_srv->settings);
|
||||
// //call rgb_mod_timer_control (start or stop) when we save settings
|
||||
// rainbow_timer_starter(app->rgb_srv);
|
||||
// rgb_backlight_settings_save(app->rgb_srv->settings);
|
||||
notification_save_settings(app);
|
||||
break;
|
||||
case LoadSettingsMessage:
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
#include "rgb_backlight.h"
|
||||
|
||||
|
||||
#define PREDEFINED_COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightPredefinedColor))
|
||||
#define COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightColor))
|
||||
|
||||
#define TAG "RGB_BACKLIGHT_SRV"
|
||||
|
||||
static const RGBBacklightPredefinedColor colors[] = {
|
||||
static const RGBBacklightColor colors[] = {
|
||||
{"Orange", 255, 60, 0},
|
||||
{"Yellow", 255, 144, 0},
|
||||
{"Spring", 167, 255, 0},
|
||||
@@ -47,43 +47,32 @@ static const RGBBacklightPredefinedColor colors[] = {
|
||||
};
|
||||
|
||||
uint8_t rgb_backlight_get_color_count(void) {
|
||||
return PREDEFINED_COLOR_COUNT;
|
||||
return COLOR_COUNT;
|
||||
}
|
||||
|
||||
const char* rgb_backlight_get_color_text(uint8_t index) {
|
||||
return colors[index].name;
|
||||
}
|
||||
|
||||
|
||||
void rgb_backlight_set_static_color(uint8_t index, float brightness) {
|
||||
// use RECORD for acces to rgb service instance and use current_* colors and static colors
|
||||
// use RECORD for acces to rgb service instance and update current colors by static
|
||||
void rgb_backlight_set_static_color(uint8_t index) {
|
||||
RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
|
||||
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
app->current_red = colors[index].red;
|
||||
app->current_green = colors[index].green;
|
||||
app->current_blue = colors[index].blue;
|
||||
|
||||
uint8_t r = app->current_red * brightness;
|
||||
uint8_t g = app->current_green * brightness;
|
||||
uint8_t b = app->current_blue * brightness;
|
||||
|
||||
SK6805_set_led_color(i, r, g, b);
|
||||
}
|
||||
|
||||
SK6805_update();
|
||||
app->current_red = colors[index].red;
|
||||
app->current_green = colors[index].green;
|
||||
app->current_blue = colors[index].blue;
|
||||
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
}
|
||||
|
||||
// void rgb_backlight_set_custom_color(uint8_t red, uint8_t green, uint8_t blue, float brightness) {
|
||||
// for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
// uint8_t r = red * (brightness);
|
||||
// uint8_t g = green * (brightness);
|
||||
// uint8_t b = blue * (brightness);
|
||||
// SK6805_set_led_color(i, r, g, b);
|
||||
// }
|
||||
// SK6805_update();
|
||||
// }
|
||||
// use RECORD for acces to rgb service instance and update current colors by custom
|
||||
void rgb_backlight_set_custom_color(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
app->current_red = red;
|
||||
app->current_green = green;
|
||||
app->current_blue = blue;
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
}
|
||||
|
||||
// apply new brightness to current display color set
|
||||
void rgb_backlight_update (float brightness) {
|
||||
@@ -96,10 +85,10 @@ void rgb_backlight_update (float brightness) {
|
||||
uint8_t b = app->current_blue * brightness;
|
||||
SK6805_set_led_color(i, r, g, b);
|
||||
}
|
||||
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
SK6805_update();
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
}
|
||||
|
||||
//start furi timer for rainbow
|
||||
void rainbow_timer_start(RGBBacklightApp* app) {
|
||||
furi_timer_start(
|
||||
@@ -115,11 +104,6 @@ void rainbow_timer_stop(RGBBacklightApp* app) {
|
||||
void rainbow_timer_starter(RGBBacklightApp* app) {
|
||||
if(app->settings->rgb_mod_installed) {
|
||||
if(app->settings->rainbow_mode > 0) {
|
||||
// rgb_backlight_set_custom_color(
|
||||
// app->rainbow_red,
|
||||
// app->rainbow_green,
|
||||
// app->rainbow_blue,
|
||||
// app->settings->brightness);
|
||||
rainbow_timer_start(app);
|
||||
} else {
|
||||
if(furi_timer_is_running(app->rainbow_timer)) {
|
||||
@@ -133,7 +117,7 @@ static void rainbow_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
RGBBacklightApp* app = context;
|
||||
|
||||
// if rgb_mode_rainbow_mode is rainbow do rainbow effect
|
||||
// if rainbow_mode is rainbow do rainbow effect
|
||||
if(app->settings->rainbow_mode == 1) {
|
||||
switch(app->rainbow_stage) {
|
||||
// from red to yellow (255,0,0) - (255,255,0)
|
||||
@@ -187,18 +171,12 @@ static void rainbow_timer_callback(void* context) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// rgb_backlight_set_custom_color(
|
||||
// app->current_red,
|
||||
// app->current_green,
|
||||
// app->current_blue,
|
||||
// app->settings->brightness);
|
||||
}
|
||||
|
||||
}
|
||||
//rgb_backlight_set_custom_color(app->current_red,app->current_green,app->current_blue);
|
||||
rgb_backlight_update (app->settings->brightness);
|
||||
|
||||
// if rgb_mode_rainbow_mode is ..... do another effect
|
||||
// if(app->settings.rainbow_mode == 2) {
|
||||
// if rainbow_mode is ..... do another effect
|
||||
// if(app->settings.rainbow_mode == ...) {
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -206,7 +184,7 @@ int32_t rgb_backlight_srv (void* p) {
|
||||
UNUSED(p);
|
||||
|
||||
// Define object app (full app with settings and running variables),
|
||||
// allocate memory and create record for access to app structure from outside
|
||||
// allocate memory and create RECORD for access to app structure from outside
|
||||
RGBBacklightApp* app = malloc(sizeof(RGBBacklightApp));
|
||||
|
||||
furi_record_create(RECORD_RGB_BACKLIGHT, app);
|
||||
@@ -220,22 +198,28 @@ int32_t rgb_backlight_srv (void* p) {
|
||||
rgb_backlight_settings_load (app->settings);
|
||||
|
||||
// Init app variables
|
||||
app->current_red = 255;
|
||||
app->current_green = 60;
|
||||
app->current_blue = 0;
|
||||
app->rainbow_stage = 1;
|
||||
|
||||
// app->current_red = 255;
|
||||
// app->current_green = 60;
|
||||
// app->current_blue = 0;
|
||||
|
||||
// а нужно ли это все при старте сервиса, если мы получим сигнал на подсветку от Нотификейшена. Может вынести в ИНИТ и при старте нотиф дернуть его 1 раз
|
||||
// if rgb_mod_installed start rainbow or set static color from settings (default index = 0)
|
||||
if(app->settings->rgb_mod_installed) {
|
||||
if(app->settings->rainbow_mode > 0 ) {
|
||||
// app->current_red = 255;
|
||||
// app->current_green = 0;
|
||||
// app->current_blue = 0;
|
||||
rainbow_timer_starter(app);
|
||||
} else {
|
||||
rgb_backlight_set_static_color(app->settings->static_color_index, app->settings->brightness);
|
||||
rgb_backlight_set_static_color(app->settings->static_color_index);
|
||||
rgb_backlight_update (app->settings->brightness);
|
||||
}
|
||||
// if not rgb_mod_installed set default static orange color (index=0)
|
||||
} else {
|
||||
rgb_backlight_set_static_color(0, app->settings->brightness);
|
||||
rgb_backlight_set_static_color(0);
|
||||
rgb_backlight_update (app->settings->brightness);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
} RGBBacklightPredefinedColor;
|
||||
} RGBBacklightColor;
|
||||
|
||||
typedef struct {
|
||||
FuriTimer* rainbow_timer;
|
||||
@@ -48,7 +48,7 @@ typedef struct {
|
||||
#define RECORD_RGB_BACKLIGHT "rgb_backlight"
|
||||
|
||||
void rgb_backlight_update (float brightness);
|
||||
void rgb_backlight_set_static_color(uint8_t index, float brightness);
|
||||
void rgb_backlight_set_static_color(uint8_t index);
|
||||
void rainbow_timer_stop(RGBBacklightApp* app);
|
||||
void rainbow_timer_start(RGBBacklightApp* app);
|
||||
void rainbow_timer_starter(RGBBacklightApp* app);
|
||||
|
||||
@@ -91,5 +91,7 @@ void rgb_backlight_settings_save(const RGBBacklightSettings* settings) {
|
||||
|
||||
if(!success) {
|
||||
FURI_LOG_E(TAG, "Failed to save rgb_backlight_settings file");
|
||||
} else {
|
||||
FURI_LOG_I(TAG, "Settings saved");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,12 +246,13 @@ static void rgb_mod_rainbow_changed(VariableItem* item) {
|
||||
variable_item_set_locked(t_item, false, "Rainbow mode\nenabled!");
|
||||
}
|
||||
}
|
||||
//save settings and start/stop rgb_mod_rainbow_timer
|
||||
notification_message_save_settings(app->notification);
|
||||
|
||||
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) {
|
||||
rgb_backlight_update(app->notification->settings.display_brightness);
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,16 +272,17 @@ static void rgb_mod_rainbow_step_changed(VariableItem* item) {
|
||||
app->notification->rgb_srv->settings->rainbow_step = rgb_mod_rainbow_step_value[index];
|
||||
}
|
||||
|
||||
// --- Set RGB backlight colors ---
|
||||
// Set rgb_backlight colors static and custom
|
||||
static void color_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
rgb_backlight_set_static_color(index,app->notification->rgb_srv->settings->brightness);
|
||||
rgb_backlight_set_static_color(index);
|
||||
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(index));
|
||||
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
// TODO: refactor and fix this
|
||||
static void color_set_custom_red(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
@@ -289,8 +291,7 @@ static void color_set_custom_red(VariableItem* item) {
|
||||
app->notification->rgb_srv->settings->custom_red = index;
|
||||
app->notification->rgb_srv->current_red = index;
|
||||
app->notification->rgb_srv->settings->static_color_index=13;
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
|
||||
|
||||
char valtext[4] = {};
|
||||
snprintf(valtext, sizeof(valtext), "%d", index);
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
@@ -299,6 +300,8 @@ static void color_set_custom_red(VariableItem* item) {
|
||||
// Set to custom color explicitly
|
||||
variable_item_set_current_value_index(temp_item, 13);
|
||||
variable_item_set_current_value_text(temp_item, rgb_backlight_get_color_text(13));
|
||||
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
static void color_set_custom_green(VariableItem* item) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,84.1,,
|
||||
Version,+,86.0,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||
@@ -3148,7 +3148,7 @@ Function,-,renameat,int,"int, const char*, int, const char*"
|
||||
Function,-,rewind,void,FILE*
|
||||
Function,+,rgb_backlight_get_color_count,uint8_t,
|
||||
Function,+,rgb_backlight_get_color_text,const char*,uint8_t
|
||||
Function,+,rgb_backlight_set_static_color,void,"uint8_t, float"
|
||||
Function,+,rgb_backlight_set_static_color,void,uint8_t
|
||||
Function,+,rgb_backlight_settings_load,void,RGBBacklightSettings*
|
||||
Function,+,rgb_backlight_settings_save,void,const RGBBacklightSettings*
|
||||
Function,+,rgb_backlight_update,void,float
|
||||
|
||||
|
Reference in New Issue
Block a user