mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Moving RGB Backlight setings and effect to rgb service finished.
This commit is contained in:
@@ -748,9 +748,6 @@ 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);
|
||||
notification_save_settings(app);
|
||||
break;
|
||||
case LoadSettingsMessage:
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <storage/storage.h>
|
||||
#include "rgb_backlight.h"
|
||||
|
||||
|
||||
#define COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightColor))
|
||||
|
||||
#define TAG "RGB_BACKLIGHT_SRV"
|
||||
@@ -47,21 +46,27 @@ static const RGBBacklightColor colors[] = {
|
||||
};
|
||||
|
||||
uint8_t rgb_backlight_get_color_count(void) {
|
||||
return COLOR_COUNT;
|
||||
}
|
||||
return COLOR_COUNT;
|
||||
}
|
||||
|
||||
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
|
||||
void rgb_backlight_set_static_color(uint8_t index) {
|
||||
RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
|
||||
app->current_red = colors[index].red;
|
||||
app->current_green = colors[index].green;
|
||||
app->current_blue = colors[index].blue;
|
||||
|
||||
//if user select "custom" value then set current colors by custom values
|
||||
if(index == 13) {
|
||||
app->current_red = app->settings->custom_red;
|
||||
app->current_green = app->settings->custom_green;
|
||||
app->current_blue = app->settings->custom_blue;
|
||||
} else {
|
||||
app->current_red = colors[index].red;
|
||||
app->current_green = colors[index].green;
|
||||
app->current_blue = colors[index].blue;
|
||||
}
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
}
|
||||
|
||||
@@ -74,15 +79,14 @@ void rgb_backlight_set_custom_color(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
}
|
||||
|
||||
// apply new brightness to current display color set
|
||||
void rgb_backlight_update (float brightness) {
|
||||
// use RECORD for acces to rgb service instance and use current_* colors
|
||||
// use RECORD for acces to rgb service instance, use current_* colors and update backlight
|
||||
void rgb_backlight_update(float brightness) {
|
||||
RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
|
||||
|
||||
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
uint8_t r = app->current_red * brightness;
|
||||
uint8_t g = app->current_green * brightness;
|
||||
uint8_t b = app->current_blue * brightness;
|
||||
uint8_t r = app->current_red * (brightness / 1.0f);
|
||||
uint8_t g = app->current_green * (brightness / 1.0f);
|
||||
uint8_t b = app->current_blue * (brightness / 1.0f);
|
||||
SK6805_set_led_color(i, r, g, b);
|
||||
}
|
||||
SK6805_update();
|
||||
@@ -91,8 +95,7 @@ void rgb_backlight_update (float brightness) {
|
||||
|
||||
//start furi timer for rainbow
|
||||
void rainbow_timer_start(RGBBacklightApp* app) {
|
||||
furi_timer_start(
|
||||
app->rainbow_timer, furi_ms_to_ticks(app->settings->rainbow_speed_ms));
|
||||
furi_timer_start(app->rainbow_timer, furi_ms_to_ticks(app->settings->rainbow_speed_ms));
|
||||
}
|
||||
|
||||
//stop furi timer for rainbow
|
||||
@@ -102,17 +105,15 @@ void rainbow_timer_stop(RGBBacklightApp* app) {
|
||||
|
||||
// if rgb_mod_installed then apply rainbow colors to backlight and start/restart/stop rainbow_timer
|
||||
void rainbow_timer_starter(RGBBacklightApp* app) {
|
||||
if(app->settings->rgb_mod_installed) {
|
||||
if(app->settings->rainbow_mode > 0) {
|
||||
rainbow_timer_start(app);
|
||||
} else {
|
||||
if(furi_timer_is_running(app->rainbow_timer)) {
|
||||
rainbow_timer_stop(app);
|
||||
}
|
||||
|
||||
if((app->settings->rainbow_mode > 0) && (app->settings->rgb_mod_installed)) {
|
||||
rainbow_timer_start(app);
|
||||
} else {
|
||||
if(furi_timer_is_running(app->rainbow_timer)) {
|
||||
rainbow_timer_stop(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rainbow_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
RGBBacklightApp* app = context;
|
||||
@@ -171,60 +172,50 @@ static void rainbow_timer_callback(void* context) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//rgb_backlight_set_custom_color(app->current_red,app->current_green,app->current_blue);
|
||||
rgb_backlight_update (app->settings->brightness);
|
||||
}
|
||||
rgb_backlight_update(app->settings->brightness);
|
||||
|
||||
// if rainbow_mode is ..... do another effect
|
||||
// if(app->settings.rainbow_mode == ...) {
|
||||
// }
|
||||
}
|
||||
|
||||
int32_t rgb_backlight_srv (void* p) {
|
||||
int32_t rgb_backlight_srv(void* p) {
|
||||
UNUSED(p);
|
||||
|
||||
// Define object app (full app with settings and running variables),
|
||||
// Define object app (full app with settings and running variables),
|
||||
// allocate memory and create RECORD for access to app structure from outside
|
||||
RGBBacklightApp* app = malloc(sizeof(RGBBacklightApp));
|
||||
|
||||
furi_record_create(RECORD_RGB_BACKLIGHT, app);
|
||||
|
||||
//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);
|
||||
|
||||
// settings load or create default
|
||||
app->settings = malloc(sizeof(RGBBacklightSettings));
|
||||
rgb_backlight_settings_load (app->settings);
|
||||
rgb_backlight_settings_load(app->settings);
|
||||
|
||||
// Init app variables
|
||||
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 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;
|
||||
if(app->settings->rainbow_mode > 0) {
|
||||
rainbow_timer_starter(app);
|
||||
} else {
|
||||
rgb_backlight_set_static_color(app->settings->static_color_index);
|
||||
rgb_backlight_update (app->settings->brightness);
|
||||
rgb_backlight_update(app->settings->brightness);
|
||||
}
|
||||
// if not rgb_mod_installed set default static orange color (index=0)
|
||||
// if rgb mod not installed - set default static orange color (index=0)
|
||||
} else {
|
||||
rgb_backlight_set_static_color(0);
|
||||
rgb_backlight_update (app->settings->brightness);
|
||||
}
|
||||
rgb_backlight_update(app->settings->brightness);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
FURI_LOG_I(TAG, "working");
|
||||
furi_delay_ms(2000);
|
||||
// place for message queue and other future options
|
||||
furi_delay_ms(5000);
|
||||
FURI_LOG_I(TAG, "Service is running");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ typedef struct {
|
||||
|
||||
#define RECORD_RGB_BACKLIGHT "rgb_backlight"
|
||||
|
||||
void rgb_backlight_update (float brightness);
|
||||
void rgb_backlight_update(float brightness);
|
||||
void rgb_backlight_set_custom_color(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void rgb_backlight_set_static_color(uint8_t index);
|
||||
void rainbow_timer_stop(RGBBacklightApp* app);
|
||||
void rainbow_timer_start(RGBBacklightApp* app);
|
||||
|
||||
@@ -48,7 +48,8 @@ void rgb_backlight_settings_load(RGBBacklightSettings* settings) {
|
||||
RGB_BACKLIGHT_SETTINGS_VER);
|
||||
// if config previous version - load it and inicialize new settings
|
||||
} else if(version == RGB_BACKLIGHT_SETTINGS_VER_PREV) {
|
||||
RGBBacklightSettingsPrevious* settings_previous = malloc(sizeof(RGBBacklightSettingsPrevious));
|
||||
RGBBacklightSettingsPrevious* settings_previous =
|
||||
malloc(sizeof(RGBBacklightSettingsPrevious));
|
||||
|
||||
success = saved_struct_load(
|
||||
RGB_BACKLIGHT_SETTINGS_PATH,
|
||||
@@ -73,8 +74,11 @@ void rgb_backlight_settings_load(RGBBacklightSettings* settings) {
|
||||
// fill settings with 0 and save to settings file;
|
||||
// Orange color (index=0) will be default
|
||||
if(!success) {
|
||||
FURI_LOG_W(TAG, "Failed to load file, using defaults 0");
|
||||
FURI_LOG_W(TAG, "Failed to load file, using defaults");
|
||||
memset(settings, 0, sizeof(RGBBacklightSettings));
|
||||
settings->brightness = 1.0f;
|
||||
settings->rainbow_speed_ms = 100;
|
||||
settings->rainbow_step = 1;
|
||||
rgb_backlight_settings_save(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <lib/toolbox/value_index.h>
|
||||
#include "applications/services/rgb_backlight/rgb_backlight.h"
|
||||
|
||||
#define MAX_NOTIFICATION_SETTINGS 4
|
||||
|
||||
@@ -108,13 +109,13 @@ const char* const vibro_text[VIBRO_COUNT] = {
|
||||
};
|
||||
const bool vibro_value[VIBRO_COUNT] = {false, true};
|
||||
|
||||
// --- RGB MOD RAINBOW ---
|
||||
#define RGB_MOD_COUNT 2
|
||||
const char* const rgb_mod_text[RGB_MOD_COUNT] = {
|
||||
// --- RGB BACKLIGHT ---
|
||||
#define RGB_MOD_INSTALLED_COUNT 2
|
||||
const char* const rgb_mod_installed_text[RGB_MOD_INSTALLED_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
const bool rgb_mod_value[RGB_MOD_COUNT] = {false, true};
|
||||
const bool rgb_mod_installed_value[RGB_MOD_INSTALLED_COUNT] = {false, true};
|
||||
|
||||
#define RGB_MOD_RAINBOW_MODE_COUNT 2
|
||||
const char* const rgb_mod_rainbow_mode_text[RGB_MOD_RAINBOW_MODE_COUNT] = {
|
||||
@@ -152,7 +153,7 @@ typedef enum {
|
||||
RGBViewId,
|
||||
} ViewId;
|
||||
|
||||
// --- END OF RGB MOD RAINBOW ---
|
||||
// --- RGB BACKLIGHT END ---
|
||||
|
||||
static void contrast_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
@@ -169,8 +170,13 @@ static void backlight_changed(VariableItem* item) {
|
||||
|
||||
variable_item_set_current_value_text(item, backlight_text[index]);
|
||||
app->notification->settings.display_brightness = backlight_value[index];
|
||||
//save brightness to rgb backlight settings too
|
||||
|
||||
//--- RGB BACKLIGHT ---
|
||||
//set selected brightness to current rgb backlight service settings and save settings
|
||||
app->notification->rgb_srv->settings->brightness = backlight_value[index];
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
//--- RGB BACKLIGHT END ---
|
||||
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
@@ -220,130 +226,155 @@ static void vibro_changed(VariableItem* item) {
|
||||
notification_message(app->notification, &sequence_single_vibro);
|
||||
}
|
||||
|
||||
// --- RGB MOD AND RAINBOW ---
|
||||
//--- RGB BACKLIGHT ---
|
||||
|
||||
static void rgb_mod_installed_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, rgb_mod_text[index]);
|
||||
app->notification->rgb_srv->settings->rgb_mod_installed = rgb_mod_value[index];
|
||||
variable_item_set_current_value_text(item, rgb_mod_installed_text[index]);
|
||||
app->notification->rgb_srv->settings->rgb_mod_installed = rgb_mod_installed_value[index];
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
// Lock/Unlock rgb settings depent from rgb_mod_installed switch
|
||||
int slide = 0;
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
slide = 1;
|
||||
}
|
||||
for(int i = slide; i < (slide + 7); i++) {
|
||||
VariableItem* t_item = variable_item_list_get(app->variable_item_list_rgb, i);
|
||||
if(index == 0) {
|
||||
variable_item_set_locked(t_item, true, "RGB MOD\nOFF!");
|
||||
} else {
|
||||
variable_item_set_locked(t_item, false, "RGB MOD\nOFF!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rgb_mod_rainbow_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, rgb_mod_rainbow_mode_text[index]);
|
||||
app->notification->rgb_srv->settings->rainbow_mode = rgb_mod_rainbow_mode_value[index];
|
||||
|
||||
rainbow_timer_starter(app->notification->rgb_srv);
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
|
||||
// Lock/Unlock color settings if rainbow mode Enabled/Disabled (0-3 index if debug off and 1-4 index if debug on)
|
||||
int slide = 0;
|
||||
if (furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {slide = 1;}
|
||||
for(int i = slide; i < (slide+4); i++) {
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
slide = 1;
|
||||
}
|
||||
for(int i = slide; i < (slide + 4); i++) {
|
||||
VariableItem* t_item = variable_item_list_get(app->variable_item_list_rgb, i);
|
||||
if(app->notification->rgb_srv->settings->rainbow_mode > 0) {
|
||||
if(index > 0) {
|
||||
variable_item_set_locked(t_item, true, "Rainbow mode\nenabled!");
|
||||
} else {
|
||||
variable_item_set_locked(t_item, false, "Rainbow mode\nenabled!");
|
||||
}
|
||||
}
|
||||
|
||||
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->rgb_srv->settings->brightness);
|
||||
rgb_backlight_set_static_color(app->notification->rgb_srv->settings->static_color_index);
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
}
|
||||
}
|
||||
|
||||
static void rgb_mod_rainbow_speed_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, rgb_mod_rainbow_speed_text[index]);
|
||||
app->notification->rgb_srv->settings->rainbow_speed_ms = rgb_mod_rainbow_speed_value[index];
|
||||
//use message for restart rgb_mod_rainbow_timer with new delay
|
||||
notification_message_save_settings(app->notification);
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
static void rgb_mod_rainbow_step_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, rgb_mod_rainbow_step_text[index]);
|
||||
app->notification->rgb_srv->settings->rainbow_step = rgb_mod_rainbow_step_value[index];
|
||||
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
// 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);
|
||||
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(index));
|
||||
|
||||
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(index));
|
||||
app->notification->rgb_srv->settings->static_color_index = index;
|
||||
|
||||
rgb_backlight_set_static_color(index);
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
//Set custom red to settings and current color
|
||||
app->notification->rgb_srv->settings->custom_red = index;
|
||||
app->notification->rgb_srv->current_red = index;
|
||||
app->notification->rgb_srv->settings->static_color_index=13;
|
||||
|
||||
app->notification->rgb_srv->settings->static_color_index = 13;
|
||||
|
||||
char valtext[4] = {};
|
||||
snprintf(valtext, sizeof(valtext), "%d", index);
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
static void color_set_custom_green(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
//Set custom green to settings and current color
|
||||
app->notification->rgb_srv->settings->custom_green = index;
|
||||
app->notification->rgb_srv->current_green = 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);
|
||||
// rgb_backlight_set_color(13);
|
||||
// rgb_backlight_update(app->rgb_srv->settings->brightness);
|
||||
|
||||
// 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));
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
static void color_set_custom_blue(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
//Set custom blue to settings and current color
|
||||
app->notification->rgb_srv->settings->custom_blue = index;
|
||||
app->notification->rgb_srv->current_blue = index;
|
||||
app->notification->rgb_srv->settings->static_color_index=13;
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
//Set custom green to settings and current color
|
||||
app->notification->rgb_srv->settings->custom_green = index;
|
||||
app->notification->rgb_srv->current_green = index;
|
||||
app->notification->rgb_srv->settings->static_color_index = 13;
|
||||
|
||||
char valtext[4] = {};
|
||||
snprintf(valtext, sizeof(valtext), "%d", index);
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
// rgb_backlight_set_color(13);
|
||||
// rgb_backlight_update(app->rgb_srv->settings->brightness);
|
||||
|
||||
|
||||
// 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));
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
|
||||
rgb_backlight_update(app->notification->rgb_srv->settings->brightness);
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
static void color_set_custom_blue(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
//Set custom blue to settings and current color
|
||||
app->notification->rgb_srv->settings->custom_blue = index;
|
||||
app->notification->rgb_srv->current_blue = index;
|
||||
app->notification->rgb_srv->settings->static_color_index = 13;
|
||||
|
||||
char valtext[4] = {};
|
||||
snprintf(valtext, sizeof(valtext), "%d", index);
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
|
||||
// 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);
|
||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||
}
|
||||
|
||||
// open rgb_settings_view if user press OK on first (index=0) menu string and (debug mode or rgb_mod_install is true)
|
||||
@@ -363,7 +394,7 @@ static uint32_t notification_app_rgb_settings_exit(void* context) {
|
||||
UNUSED(context);
|
||||
return MainViewId;
|
||||
}
|
||||
// --- END OF RGB MOD AND RAINBOW ---
|
||||
//--- RGB BACKLIGHT END ---
|
||||
|
||||
static uint32_t notification_app_settings_exit(void* context) {
|
||||
UNUSED(context);
|
||||
@@ -378,21 +409,23 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
app->variable_item_list = variable_item_list_alloc();
|
||||
View* view = variable_item_list_get_view(app->variable_item_list);
|
||||
|
||||
//set callback for exit from view
|
||||
view_set_previous_callback(view, notification_app_settings_exit);
|
||||
|
||||
// set callback for OK pressed in menu
|
||||
variable_item_list_set_enter_callback(
|
||||
app->variable_item_list, variable_item_list_enter_callback, app);
|
||||
|
||||
VariableItem* item;
|
||||
uint8_t value_index;
|
||||
|
||||
//set callback for exit from main view
|
||||
view_set_previous_callback(view, notification_app_settings_exit);
|
||||
|
||||
//--- RGB BACKLIGHT ---
|
||||
// set callback for OK pressed in notification settings menu
|
||||
variable_item_list_set_enter_callback(
|
||||
app->variable_item_list, variable_item_list_enter_callback, app);
|
||||
|
||||
//Show RGB settings only when debug_mode or rgb_mod_installed is active
|
||||
if((app->notification->rgb_srv->settings->rgb_mod_installed) ||
|
||||
(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug))) {
|
||||
item = variable_item_list_add(app->variable_item_list, "RGB mod settings", 0, NULL, app);
|
||||
}
|
||||
//--- RGB BACKLIGHT END ---
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list, "LCD Contrast", CONTRAST_COUNT, contrast_changed, app);
|
||||
@@ -450,9 +483,10 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_text(item, vibro_text[value_index]);
|
||||
}
|
||||
|
||||
// --- RGB SETTINGS VIEW ---
|
||||
//--- RGB BACKLIGHT ---
|
||||
app->variable_item_list_rgb = variable_item_list_alloc();
|
||||
View* view_rgb = variable_item_list_get_view(app->variable_item_list_rgb);
|
||||
|
||||
// set callback for OK pressed in rgb_settings_menu
|
||||
view_set_previous_callback(view_rgb, notification_app_rgb_settings_exit);
|
||||
|
||||
@@ -461,16 +495,18 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"RGB MOD Installed",
|
||||
RGB_MOD_COUNT,
|
||||
RGB_MOD_INSTALLED_COUNT,
|
||||
rgb_mod_installed_changed,
|
||||
app);
|
||||
value_index = value_index_bool(
|
||||
app->notification->rgb_srv->settings->rgb_mod_installed, rgb_mod_value, RGB_MOD_COUNT);
|
||||
app->notification->rgb_srv->settings->rgb_mod_installed,
|
||||
rgb_mod_installed_value,
|
||||
RGB_MOD_INSTALLED_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, rgb_mod_text[value_index]);
|
||||
variable_item_set_current_value_text(item, rgb_mod_installed_text[value_index]);
|
||||
}
|
||||
|
||||
// RGB Colors settings
|
||||
// Static Colors settings
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
"LCD Color",
|
||||
@@ -482,6 +518,9 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(value_index));
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rainbow_mode > 0), "Rainbow mode\nenabled!");
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rgb_mod_installed == 0), "RGB MOD \nOFF!");
|
||||
|
||||
temp_item = item;
|
||||
|
||||
// Custom Color - REFACTOR THIS
|
||||
@@ -494,6 +533,8 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rainbow_mode > 0), "Rainbow mode\nenabled!");
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rgb_mod_installed == 0), "RGB MOD \nOFF!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb, "Custom Green", 255, color_set_custom_green, app);
|
||||
@@ -503,6 +544,8 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rainbow_mode > 0), "Rainbow mode\nenabled!");
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rgb_mod_installed == 0), "RGB MOD \nOFF!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb, "Custom Blue", 255, color_set_custom_blue, app);
|
||||
@@ -512,6 +555,8 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_text(item, valtext);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rainbow_mode > 0), "Rainbow mode\nenabled!");
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rgb_mod_installed == 0), "RGB MOD \nOFF!");
|
||||
|
||||
// Rainbow (based on Willy-JL idea) settings
|
||||
item = variable_item_list_add(
|
||||
@@ -526,6 +571,8 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
RGB_MOD_RAINBOW_MODE_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, rgb_mod_rainbow_mode_text[value_index]);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rgb_mod_installed == 0), "RGB MOD \nOFF!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
@@ -539,6 +586,8 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
RGB_MOD_RAINBOW_SPEED_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, rgb_mod_rainbow_speed_text[value_index]);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rgb_mod_installed == 0), "RGB MOD \nOFF!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list_rgb,
|
||||
@@ -552,8 +601,10 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
RGB_MOD_RAINBOW_SPEED_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, rgb_mod_rainbow_step_text[value_index]);
|
||||
variable_item_set_locked(
|
||||
item, (app->notification->rgb_srv->settings->rgb_mod_installed == 0), "RGB MOD \nOFF!");
|
||||
|
||||
// --- End of RGB SETTING VIEW ---
|
||||
//--- RGB BACKLIGHT END ---
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
3
targets/f7/api_symbols.csv
Normal file → Executable file
3
targets/f7/api_symbols.csv
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,86.0,,
|
||||
Version,+,83.1,,
|
||||
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,6 +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_custom_color,void,"uint8_t, uint8_t, uint8_t"
|
||||
Function,+,rgb_backlight_set_static_color,void,uint8_t
|
||||
Function,+,rgb_backlight_settings_load,void,RGBBacklightSettings*
|
||||
Function,+,rgb_backlight_settings_save,void,const RGBBacklightSettings*
|
||||
|
||||
|
@@ -32,23 +32,25 @@ void furi_hal_light_init(void) {
|
||||
}
|
||||
|
||||
void furi_hal_light_set(Light light, uint8_t value) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
if(light & LightRed) {
|
||||
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelRed, value);
|
||||
}
|
||||
if(light & LightGreen) {
|
||||
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelGreen, value);
|
||||
}
|
||||
if(light & LightBlue) {
|
||||
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelBlue, value);
|
||||
}
|
||||
if(light & LightBacklight) {
|
||||
uint8_t prev = lp5562_get_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelWhite);
|
||||
lp5562_execute_ramp(
|
||||
&furi_hal_i2c_handle_power, LP5562Engine1, LP5562ChannelWhite, prev, value, 100);
|
||||
rgb_backlight_update(value);
|
||||
}
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
if(light & LightRed) {
|
||||
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelRed, value);
|
||||
}
|
||||
if(light & LightGreen) {
|
||||
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelGreen, value);
|
||||
}
|
||||
if(light & LightBlue) {
|
||||
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelBlue, value);
|
||||
}
|
||||
if(light & LightBacklight) {
|
||||
uint8_t prev = lp5562_get_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelWhite);
|
||||
lp5562_execute_ramp(
|
||||
&furi_hal_i2c_handle_power, LP5562Engine1, LP5562ChannelWhite, prev, value, 100);
|
||||
// --- RGB BACKLIGHT ---
|
||||
rgb_backlight_update(value / 255.0f);
|
||||
// --- RGB BACKLIGHT END ---
|
||||
}
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
}
|
||||
|
||||
void furi_hal_light_blink_start(Light light, uint8_t brightness, uint16_t on_time, uint16_t period) {
|
||||
|
||||
Reference in New Issue
Block a user