Allow using system backlight color

This commit is contained in:
2026-06-13 15:16:39 -04:00
parent 66831e4833
commit d067194cb5
6 changed files with 40 additions and 3 deletions
+1
View File
@@ -2,3 +2,4 @@
/.clangd
/.lock-waf*
/package-lock.json
/node_modules
+1
View File
@@ -30,6 +30,7 @@
"PKJS_TEMP_BAR_COUNT",
"CLAY_BT_INDICATOR",
"CLAY_SHOW_TIME_MG",
"CLAY_USE_CUSTOM_LED",
"CLAY_DATE_TIMEOUT",
"CLAY_LOW_FUEL_PERCENT",
"CLAY_LED_COLOR",
+10 -1
View File
@@ -218,7 +218,11 @@ static void accel_tap_handler(AccelAxisType axis, int32_t direction) {
static void apply_settings(bool first_run) {
// LED&BG
light_set_color(settings.ColorLED); // no-op on unsupported platforms
if (settings.UseCustomLED) {
light_set_color(settings.ColorLED); // no-op on unsupported platforms
} else {
light_set_system_color();
}
window_set_background_color(s_main_window, settings.ColorBG);
// TIME MG
@@ -381,6 +385,7 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
// CLAY SETTINGS
Tuple *track_bt_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BT_INDICATOR);
Tuple *show_time_mg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_SHOW_TIME_MG);
Tuple *use_custom_led_tuple = dict_find(iter, MESSAGE_KEY_CLAY_USE_CUSTOM_LED);
Tuple *date_timeout_tuple = dict_find(iter, MESSAGE_KEY_CLAY_DATE_TIMEOUT);
Tuple *low_fuel_percent_tuple = dict_find(iter, MESSAGE_KEY_CLAY_LOW_FUEL_PERCENT);
Tuple *color_led_tuple = dict_find(iter, MESSAGE_KEY_CLAY_LED_COLOR);
@@ -397,6 +402,9 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
if (show_time_mg_tuple) {
settings.ShowTimeMG = show_time_mg_tuple->value->uint8;
}
if (use_custom_led_tuple) {
settings.UseCustomLED = use_custom_led_tuple->value->uint8;
}
if (date_timeout_tuple) {
settings.DateTimeoutSecs = date_timeout_tuple->value->uint8;
}
@@ -438,6 +446,7 @@ static void init() {
} else {
settings.TrackBTStatus = false;
settings.ShowTimeMG = false;
settings.UseCustomLED = false;
settings.DateTimeoutSecs = 3;
settings.LowFuelPercent = 20;
settings.ColorLED = GColorWhite;
+1
View File
@@ -6,6 +6,7 @@
typedef struct ClaySettings {
bool TrackBTStatus;
bool ShowTimeMG;
bool UseCustomLED;
uint8_t DateTimeoutSecs;
uint8_t LowFuelPercent;
GColor ColorLED;
+9 -1
View File
@@ -89,12 +89,20 @@ module.exports = [
}
]
},
{
"id": "custom_led_toggle",
"type": "toggle",
"messageKey": "CLAY_USE_CUSTOM_LED",
"defaultValue": false,
"label": "Use custom backlight color",
"description": "Enable to override your system-wide setting.",
},
{
"id": "custom_color_led",
"type": "color",
"messageKey": "CLAY_LED_COLOR",
"defaultValue": "ffffff",
"label": "Backlight color (Time 2)",
"label": "Backlight color",
"sunlight": false,
},
{
+18 -1
View File
@@ -4,11 +4,21 @@ module.exports = function (minified) {
var $ = minified.$;
var HTML = minified.HTML;
function toggleCustomBacklight() {
if (this.get()) {
clayConfig.getItemById('custom_color_led').enable();
} else {
clayConfig.getItemById('custom_color_led').disable();
}
}
function setColorsToPreset() {
var selectedPreset = clayConfig.getItemById('color_preset_selector').get();
switch (selectedPreset) {
case 'civic_si':
clayConfig.getItemById('custom_led_toggle').set(true); // override system with red backlight
clayConfig.getItemById('custom_color_led').set('ff0000');
clayConfig.getItemById('custom_color_bg').set('000000');
clayConfig.getItemById('custom_color_mg_bars').set('555555');
clayConfig.getItemById('custom_color_cool_bars').set('0000aa');
@@ -18,7 +28,8 @@ module.exports = function (minified) {
clayConfig.getItemById('custom_color_warning').set('ffaa00');
break
default:
clayConfig.getItemById('custom_color_led').set('ffffff');
clayConfig.getItemById('custom_led_toggle').set(false); // use system LED color
clayConfig.getItemById('custom_color_bg').set('0000ff');
clayConfig.getItemById('custom_color_mg_bars').set('555555');
clayConfig.getItemById('custom_color_cool_bars').set('0000aa');
@@ -32,6 +43,7 @@ module.exports = function (minified) {
function toggleCustomColors() {
if (this.get()) {
clayConfig.getItemById('color_preset_selector').hide();
clayConfig.getItemById('custom_led_toggle').show();
clayConfig.getItemById('custom_color_led').show();
clayConfig.getItemById('custom_color_bg').show();
clayConfig.getItemById('custom_color_mg_bars').show();
@@ -43,6 +55,7 @@ module.exports = function (minified) {
} else {
setColorsToPreset();
clayConfig.getItemById('color_preset_selector').show();
clayConfig.getItemById('custom_led_toggle').hide();
clayConfig.getItemById('custom_color_led').hide();
clayConfig.getItemById('custom_color_bg').hide();
clayConfig.getItemById('custom_color_mg_bars').hide();
@@ -59,6 +72,10 @@ module.exports = function (minified) {
toggleCustomColors.call(customColorsToggle);
customColorsToggle.on('change', toggleCustomColors);
var customBacklightToggle = clayConfig.getItemById('custom_led_toggle');
toggleCustomBacklight.call(customBacklightToggle);
customBacklightToggle.on('change', toggleCustomBacklight);
clayConfig.getItemById('color_preset_selector').on('change', setColorsToPreset);
});
};