mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 15:58:36 -07:00
Set rgb backlight leds individually
This commit is contained in:
@@ -4,7 +4,9 @@ enum VarItemListIndex {
|
||||
VarItemListIndexDarkMode,
|
||||
VarItemListIndexLeftHanded,
|
||||
VarItemListIndexRgbBacklight,
|
||||
VarItemListIndexLcdColor,
|
||||
VarItemListIndexLcdColor0,
|
||||
VarItemListIndexLcdColor1,
|
||||
VarItemListIndexLcdColor2,
|
||||
VarItemListIndexRainbowLcd,
|
||||
VarItemListIndexRainbowSpeed,
|
||||
VarItemListIndexRainbowInterval,
|
||||
@@ -56,13 +58,22 @@ static const struct {
|
||||
{"Brown", {165, 42, 42}},
|
||||
{"White", {255, 192, 203}},
|
||||
};
|
||||
static void xtreme_app_scene_misc_screen_lcd_color_changed(VariableItem* item) {
|
||||
static void xtreme_app_scene_misc_screen_lcd_color_changed(VariableItem* item, uint8_t led) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, lcd_colors[index].name);
|
||||
rgb_backlight_set_color(lcd_colors[index].color);
|
||||
rgb_backlight_set_color(led, lcd_colors[index].color);
|
||||
app->save_backlight = true;
|
||||
}
|
||||
static void xtreme_app_scene_misc_screen_lcd_color_0_changed(VariableItem* item) {
|
||||
xtreme_app_scene_misc_screen_lcd_color_changed(item, 0);
|
||||
}
|
||||
static void xtreme_app_scene_misc_screen_lcd_color_1_changed(VariableItem* item) {
|
||||
xtreme_app_scene_misc_screen_lcd_color_changed(item, 1);
|
||||
}
|
||||
static void xtreme_app_scene_misc_screen_lcd_color_2_changed(VariableItem* item) {
|
||||
xtreme_app_scene_misc_screen_lcd_color_changed(item, 2);
|
||||
}
|
||||
|
||||
const char* const rainbow_lcd_names[RGBBacklightRainbowModeCount] = {
|
||||
"OFF",
|
||||
@@ -148,24 +159,32 @@ void xtreme_app_scene_misc_screen_on_enter(void* context) {
|
||||
item = variable_item_list_add(var_item_list, "RGB Backlight", 1, NULL, app);
|
||||
variable_item_set_current_value_text(item, xtreme_settings->rgb_backlight ? "ON" : "OFF");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"LCD Color",
|
||||
COUNT_OF(lcd_colors),
|
||||
xtreme_app_scene_misc_screen_lcd_color_changed,
|
||||
app);
|
||||
RgbColor color = rgb_backlight_get_color();
|
||||
bool found = false;
|
||||
for(size_t i = 0; i < COUNT_OF(lcd_colors); i++) {
|
||||
if(rgbcmp(&color, &lcd_colors[i].color) == 0) {
|
||||
struct {
|
||||
uint8_t led;
|
||||
const char* str;
|
||||
VariableItemChangeCallback cb;
|
||||
} lcd_cols[] = {
|
||||
{0, "LCD Left", xtreme_app_scene_misc_screen_lcd_color_0_changed},
|
||||
{1, "LCD Middle", xtreme_app_scene_misc_screen_lcd_color_1_changed},
|
||||
{2, "LCD Right", xtreme_app_scene_misc_screen_lcd_color_2_changed},
|
||||
};
|
||||
size_t lcd_sz = COUNT_OF(lcd_colors);
|
||||
|
||||
for(size_t i = 0; i < COUNT_OF(lcd_cols); i++) {
|
||||
item = variable_item_list_add(var_item_list, lcd_cols[i].str, lcd_sz, lcd_cols[i].cb, app);
|
||||
RgbColor color = rgb_backlight_get_color(lcd_cols[i].led);
|
||||
bool found = false;
|
||||
for(size_t i = 0; i < lcd_sz; i++) {
|
||||
if(rgbcmp(&color, &lcd_colors[i].color) != 0) continue;
|
||||
value_index = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
variable_item_set_current_value_index(item, found ? value_index : lcd_sz);
|
||||
variable_item_set_current_value_text(
|
||||
item, found ? lcd_colors[value_index].name : "Custom");
|
||||
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
|
||||
}
|
||||
variable_item_set_current_value_index(item, found ? value_index : COUNT_OF(lcd_colors));
|
||||
variable_item_set_current_value_text(item, found ? lcd_colors[value_index].name : "Custom");
|
||||
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
@@ -252,7 +271,13 @@ bool xtreme_app_scene_misc_screen_on_event(void* context, SceneManagerEvent even
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VarItemListIndexLcdColor:
|
||||
case VarItemListIndexLcdColor0:
|
||||
case VarItemListIndexLcdColor1:
|
||||
case VarItemListIndexLcdColor2:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
XtremeAppSceneMiscScreenColor,
|
||||
event.event - VarItemListIndexLcdColor0);
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMiscScreenColor);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -16,7 +16,8 @@ void xtreme_app_scene_misc_screen_color_on_enter(void* context) {
|
||||
|
||||
byte_input_set_header_text(byte_input, "Set LCD Color (#RRGGBB)");
|
||||
|
||||
app->lcd_color = rgb_backlight_get_color();
|
||||
app->lcd_color = rgb_backlight_get_color(
|
||||
scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneMiscScreenColor));
|
||||
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
@@ -37,7 +38,9 @@ bool xtreme_app_scene_misc_screen_color_on_event(void* context, SceneManagerEven
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case ByteInputResultOk:
|
||||
rgb_backlight_set_color(app->lcd_color);
|
||||
rgb_backlight_set_color(
|
||||
scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneMiscScreenColor),
|
||||
app->lcd_color);
|
||||
app->save_backlight = true;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user