mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-11 23:38:11 -07:00
Add rgb backlight rainbow saturation option
This commit is contained in:
@@ -10,6 +10,7 @@ enum VarItemListIndex {
|
||||
VarItemListIndexRainbowLcd,
|
||||
VarItemListIndexRainbowSpeed,
|
||||
VarItemListIndexRainbowInterval,
|
||||
VarItemListIndexRainbowSaturation,
|
||||
};
|
||||
|
||||
void xtreme_app_scene_misc_screen_var_item_list_callback(void* context, uint32_t index) {
|
||||
@@ -138,6 +139,16 @@ static void xtreme_app_scene_misc_screen_rainbow_interval_changed(VariableItem*
|
||||
app->save_backlight = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_misc_screen_rainbow_saturation_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item) + 1;
|
||||
char str[4];
|
||||
snprintf(str, sizeof(str), "%d", index);
|
||||
variable_item_set_current_value_text(item, str);
|
||||
rgb_backlight_set_rainbow_saturation(index);
|
||||
app->save_backlight = true;
|
||||
}
|
||||
|
||||
void xtreme_app_scene_misc_screen_on_enter(void* context) {
|
||||
XtremeApp* app = context;
|
||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||
@@ -210,9 +221,9 @@ void xtreme_app_scene_misc_screen_on_enter(void* context) {
|
||||
app);
|
||||
value_index = rgb_backlight_get_rainbow_speed();
|
||||
variable_item_set_current_value_index(item, value_index - 1);
|
||||
char str[4];
|
||||
snprintf(str, sizeof(str), "%d", value_index);
|
||||
variable_item_set_current_value_text(item, str);
|
||||
char speed_str[4];
|
||||
snprintf(speed_str, sizeof(speed_str), "%d", value_index);
|
||||
variable_item_set_current_value_text(item, speed_str);
|
||||
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
@@ -229,6 +240,19 @@ void xtreme_app_scene_misc_screen_on_enter(void* context) {
|
||||
variable_item_set_current_value_text(item, rainbow_interval_names[value_index]);
|
||||
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"Rainbow Saturation",
|
||||
25,
|
||||
xtreme_app_scene_misc_screen_rainbow_saturation_changed,
|
||||
app);
|
||||
value_index = rgb_backlight_get_rainbow_saturation();
|
||||
variable_item_set_current_value_index(item, value_index - 1);
|
||||
char saturation_str[4];
|
||||
snprintf(saturation_str, sizeof(saturation_str), "%d", value_index);
|
||||
variable_item_set_current_value_text(item, saturation_str);
|
||||
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
var_item_list, xtreme_app_scene_misc_screen_var_item_list_callback, app);
|
||||
|
||||
|
||||
@@ -2561,6 +2561,7 @@ Function,+,rgb2hsv,HsvColor,RgbColor
|
||||
Function,+,rgb_backlight_get_color,RgbColor,uint8_t
|
||||
Function,+,rgb_backlight_get_rainbow_interval,uint32_t,
|
||||
Function,+,rgb_backlight_get_rainbow_mode,RGBBacklightRainbowMode,
|
||||
Function,+,rgb_backlight_get_rainbow_saturation,uint8_t,
|
||||
Function,+,rgb_backlight_get_rainbow_speed,uint8_t,
|
||||
Function,-,rgb_backlight_load_settings,void,
|
||||
Function,+,rgb_backlight_reconfigure,void,_Bool
|
||||
@@ -2568,6 +2569,7 @@ Function,+,rgb_backlight_save_settings,void,
|
||||
Function,+,rgb_backlight_set_color,void,"uint8_t, RgbColor"
|
||||
Function,+,rgb_backlight_set_rainbow_interval,void,uint32_t
|
||||
Function,+,rgb_backlight_set_rainbow_mode,void,RGBBacklightRainbowMode
|
||||
Function,+,rgb_backlight_set_rainbow_saturation,void,uint8_t
|
||||
Function,+,rgb_backlight_set_rainbow_speed,void,uint8_t
|
||||
Function,-,rgb_backlight_update,void,"uint8_t, _Bool"
|
||||
Function,+,rgbcmp,int,"const RgbColor*, const RgbColor*"
|
||||
|
||||
|
@@ -31,6 +31,7 @@ static struct {
|
||||
RGBBacklightRainbowMode rainbow_mode;
|
||||
uint8_t rainbow_speed;
|
||||
uint32_t rainbow_interval;
|
||||
uint32_t rainbow_saturation;
|
||||
} rgb_settings = {
|
||||
.colors =
|
||||
{
|
||||
@@ -41,6 +42,7 @@ static struct {
|
||||
.rainbow_mode = RGBBacklightRainbowModeOff,
|
||||
.rainbow_speed = 5,
|
||||
.rainbow_interval = 250,
|
||||
.rainbow_saturation = 255,
|
||||
};
|
||||
|
||||
static struct {
|
||||
@@ -89,6 +91,7 @@ void rgb_backlight_reconfigure(bool enabled) {
|
||||
furi_timer_free(rgb_state.rainbow_timer);
|
||||
rgb_state.rainbow_timer = NULL;
|
||||
}
|
||||
rgb_state.rainbow_hsv.s = rgb_settings.rainbow_saturation;
|
||||
|
||||
rgb_backlight_update(rgb_state.last_brightness, false);
|
||||
}
|
||||
@@ -183,6 +186,21 @@ uint32_t rgb_backlight_get_rainbow_interval() {
|
||||
return rgb_settings.rainbow_interval;
|
||||
}
|
||||
|
||||
void rgb_backlight_set_rainbow_saturation(uint8_t rainbow_saturation) {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
rgb_settings.rainbow_saturation = rainbow_saturation;
|
||||
rgb_backlight_reconfigure(rgb_state.enabled);
|
||||
}
|
||||
|
||||
uint8_t rgb_backlight_get_rainbow_saturation() {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
return rgb_settings.rainbow_saturation;
|
||||
}
|
||||
|
||||
void rgb_backlight_update(uint8_t brightness, bool tick) {
|
||||
if(!rgb_state.enabled) return;
|
||||
if(!rgb_state.settings_loaded) {
|
||||
|
||||
@@ -86,6 +86,15 @@ void rgb_backlight_set_rainbow_interval(uint32_t rainbow_interval);
|
||||
|
||||
uint32_t rgb_backlight_get_rainbow_interval();
|
||||
|
||||
/**
|
||||
* @brief Change rainbow saturation
|
||||
*
|
||||
* @param rainbow_saturation What saturation to use (0 - 255)
|
||||
*/
|
||||
void rgb_backlight_set_rainbow_saturation(uint8_t rainbow_saturation);
|
||||
|
||||
uint8_t rgb_backlight_get_rainbow_saturation();
|
||||
|
||||
/**
|
||||
* @brief Apply current RGB lighting settings
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user