From 206b066a5813d17c938590abc2f376d9808451af Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sat, 27 Jun 2026 19:59:14 -0400 Subject: [PATCH] Settings re-org (prep for separate hour and minute colors) --- package.json | 24 +++++++------- src/c/main.c | 74 ++++++++++++++++++++++++------------------ src/c/settings.h | 8 +++-- src/pkjs/config.js | 40 ++++++++++++++++------- src/pkjs/customClay.js | 16 ++++++--- 5 files changed, 100 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index 2afd151..509f07f 100644 --- a/package.json +++ b/package.json @@ -29,19 +29,21 @@ "PKJS_READY", "PKJS_TEMP_BAR_COUNT", "CLAY_ENABLE_PEEK", - "CLAY_BT_INDICATOR", "CLAY_SHOW_TIME_MG", - "CLAY_USE_CUSTOM_LED", - "CLAY_DATE_TIMEOUT", + "CLAY_TRACK_BT_STATUS", + "CLAY_DATE_TIMEOUT_SECS", "CLAY_LOW_FUEL_PERCENT", - "CLAY_LED_COLOR", - "CLAY_BG_COLOR", - "CLAY_BAR_MG_COLOR", - "CLAY_BAR_COOL_COLOR", - "CLAY_BAR_HOT_COLOR", - "CLAY_TIME_MG_COLOR", - "CLAY_FG_COLOR", - "CLAY_WARNING_COLOR" + "CLAY_USE_CUSTOM_LED", + "CLAY_COLOR_LED", + "CLAY_COLOR_BG", + "CLAY_COLOR_BAR_MG", + "CLAY_COLOR_BAR_COOL", + "CLAY_COLOR_BAR_HOT", + "CLAY_COLOR_TIME_MG", + "CLAY_COLOR_LETTERS", + "CLAY_COLOR_HOURS", + "CLAY_COLOR_MINUTES", + "CLAY_COLOR_WARNING" ], "resources": { "media": [ diff --git a/src/c/main.c b/src/c/main.c index 169e9d6..8a24fdc 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -58,7 +58,7 @@ static void toggle_fuel_warning_state(bool enable_warning, bool force) { if (!force && (enable_warning == s_fuel_is_warning)) { return; } - GColor dst = enable_warning ? settings.ColorWarning : settings.ColorFG; + GColor dst = enable_warning ? settings.ColorWarning : settings.ColorLetters; if (s_first_settings_application && !enable_warning && dst.argb == s_applied_e_f.argb) { // at startup, s_applied_e.argb is GColorWhite // for those using white fg, do not pointlessly replace white at startup if that is the destination anyway @@ -74,7 +74,7 @@ static void toggle_temp_warning_state(bool enable_warning, bool force) { if (!force && (enable_warning == s_temp_is_warning)) { return; } - GColor dst = enable_warning ? settings.ColorWarning : settings.ColorFG; + GColor dst = enable_warning ? settings.ColorWarning : settings.ColorLetters; if (s_first_settings_application && !enable_warning && dst.argb == s_applied_c_h.argb) { // at startup, s_applied_c_h.argb is GColorWhite // for those using white fg, do not pointlessly replace white at startup if that is the destination anyway @@ -87,7 +87,7 @@ static void toggle_temp_warning_state(bool enable_warning, bool force) { } static void bt_callback(bool connected) { - GColor dst = connected ? settings.ColorFG : settings.ColorWarning; + GColor dst = connected ? settings.ColorHours : settings.ColorWarning; if (s_first_settings_application && connected && dst.argb == s_applied_time_date.argb) { // at startup, s_applied_time_date.argb is GColorWhite // for those using white fg, do not pointlessly replace white at startup if that is the destination anyway @@ -528,57 +528,65 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) { // CLAY SETTINGS Tuple *enable_peek_tuple = dict_find(iter, MESSAGE_KEY_CLAY_ENABLE_PEEK); - 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 *track_bt_status_tuple = dict_find(iter, MESSAGE_KEY_CLAY_TRACK_BT_STATUS); + Tuple *date_timeout_secs_tuple = dict_find(iter, MESSAGE_KEY_CLAY_DATE_TIMEOUT_SECS); 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); - Tuple *color_bg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BG_COLOR); - Tuple *color_mg_bar_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BAR_MG_COLOR); - Tuple *color_cool_bar_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BAR_COOL_COLOR); - Tuple *color_hot_bar_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BAR_HOT_COLOR); - Tuple *color_mg_time_tuple = dict_find(iter, MESSAGE_KEY_CLAY_TIME_MG_COLOR); - Tuple *color_fg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_FG_COLOR); - Tuple *color_warning_tuple = dict_find(iter, MESSAGE_KEY_CLAY_WARNING_COLOR); + Tuple *use_custom_led_tuple = dict_find(iter, MESSAGE_KEY_CLAY_USE_CUSTOM_LED); + Tuple *color_led_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_LED); + Tuple *color_bg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_BG); + Tuple *color_bar_mg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_BAR_MG); + Tuple *color_bar_cool_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_BAR_COOL); + Tuple *color_bar_hot_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_BAR_HOT); + Tuple *color_time_mg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_TIME_MG); + Tuple *color_letters_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_LETTERS); + Tuple *color_hours_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_HOURS); + Tuple *color_minutes_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_MINUTES); + Tuple *color_warning_tuple = dict_find(iter, MESSAGE_KEY_CLAY_COLOR_WARNING); if (enable_peek_tuple) { settings.EnablePeek = enable_peek_tuple->value->uint8; } - if (track_bt_tuple) { - settings.TrackBTStatus = track_bt_tuple->value->uint8; - } 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 (track_bt_status_tuple) { + settings.TrackBTStatus = track_bt_status_tuple->value->uint8; } - if (date_timeout_tuple) { - settings.DateTimeoutSecs = date_timeout_tuple->value->uint8; + if (date_timeout_secs_tuple) { + settings.DateTimeoutSecs = date_timeout_secs_tuple->value->uint8; } if (low_fuel_percent_tuple) { settings.LowFuelPercent = low_fuel_percent_tuple->value->uint8; } + if (use_custom_led_tuple) { + settings.UseCustomLED = use_custom_led_tuple->value->uint8; + } if (color_led_tuple) { settings.ColorLED = GColorFromHEX(color_led_tuple->value->int32); } if (color_bg_tuple) { settings.ColorBG = GColorFromHEX(color_bg_tuple->value->int32); } - if (color_mg_bar_tuple) { - settings.ColorMGBars = GColorFromHEX(color_mg_bar_tuple->value->int32); + if (color_bar_mg_tuple) { + settings.ColorMGBars = GColorFromHEX(color_bar_mg_tuple->value->int32); } - if (color_cool_bar_tuple) { - settings.ColorBarsCool = GColorFromHEX(color_cool_bar_tuple->value->int32); + if (color_bar_cool_tuple) { + settings.ColorBarsCool = GColorFromHEX(color_bar_cool_tuple->value->int32); } - if (color_hot_bar_tuple) { - settings.ColorBarsHot = GColorFromHEX(color_hot_bar_tuple->value->int32); + if (color_bar_hot_tuple) { + settings.ColorBarsHot = GColorFromHEX(color_bar_hot_tuple->value->int32); } - if (color_mg_time_tuple) { - settings.ColorMGTime = GColorFromHEX(color_mg_time_tuple->value->int32); + if (color_time_mg_tuple) { + settings.ColorMGTime = GColorFromHEX(color_time_mg_tuple->value->int32); } - if (color_fg_tuple) { - settings.ColorFG = GColorFromHEX(color_fg_tuple->value->int32); + if (color_letters_tuple) { + settings.ColorLetters = GColorFromHEX(color_letters_tuple->value->int32); + } + if (color_hours_tuple) { + settings.ColorHours = GColorFromHEX(color_hours_tuple->value->int32); + } + if (color_minutes_tuple) { + settings.ColorMinutes = GColorFromHEX(color_minutes_tuple->value->int32); } if (color_warning_tuple) { settings.ColorWarning = GColorFromHEX(color_warning_tuple->value->int32); @@ -604,7 +612,9 @@ static void init() { settings.ColorBarsCool = GColorDukeBlue; settings.ColorBarsHot = GColorRed; settings.ColorMGTime = GColorDarkGray; - settings.ColorFG = GColorWhite; + settings.ColorLetters = GColorWhite; + settings.ColorHours = GColorWhite; + settings.ColorMinutes = GColorWhite; settings.ColorWarning = GColorChromeYellow; } diff --git a/src/c/settings.h b/src/c/settings.h index 778d33c..acce5fc 100644 --- a/src/c/settings.h +++ b/src/c/settings.h @@ -5,18 +5,20 @@ typedef struct ClaySettings { bool EnablePeek; - bool TrackBTStatus; bool ShowTimeMG; - bool UseCustomLED; + bool TrackBTStatus; uint8_t DateTimeoutSecs; uint8_t LowFuelPercent; + bool UseCustomLED; GColor ColorLED; GColor ColorBG; GColor ColorMGBars; GColor ColorBarsCool; GColor ColorBarsHot; GColor ColorMGTime; - GColor ColorFG; + GColor ColorLetters; + GColor ColorHours; + GColor ColorMinutes; GColor ColorWarning; } __attribute__((__packed__)) ClaySettings; diff --git a/src/pkjs/config.js b/src/pkjs/config.js index fec6050..1955232 100644 --- a/src/pkjs/config.js +++ b/src/pkjs/config.js @@ -30,14 +30,14 @@ module.exports = [ { "id": "bt_indicator_toggle", "type": "toggle", - "messageKey": "CLAY_BT_INDICATOR", + "messageKey": "CLAY_TRACK_BT_STATUS", "defaultValue": false, "label": "BT disconnect indicator", "description": "Change the color of the digits to the configured warning color when the connection to the phone is lost." }, { "type": "slider", - "messageKey": "CLAY_DATE_TIMEOUT", + "messageKey": "CLAY_DATE_TIMEOUT_SECS", defaultValue: 3, min: 0, max: 15, @@ -108,7 +108,7 @@ module.exports = [ { "id": "custom_color_led", "type": "color", - "messageKey": "CLAY_LED_COLOR", + "messageKey": "CLAY_COLOR_LED", "defaultValue": "ffffff", "label": "Backlight color", "sunlight": false, @@ -116,7 +116,7 @@ module.exports = [ { "id": "custom_color_bg", "type": "color", - "messageKey": "CLAY_BG_COLOR", + "messageKey": "CLAY_COLOR_BG", "defaultValue": "0000ff", "label": "Background color", "sunlight": false, @@ -124,7 +124,7 @@ module.exports = [ { "id": "custom_color_mg_bars", "type": "color", - "messageKey": "CLAY_BAR_MG_COLOR", + "messageKey": "CLAY_COLOR_BAR_MG", "defaultValue": "aaaaaa", "label": "Bar midground color", "sunlight": false, @@ -132,7 +132,7 @@ module.exports = [ { "id": "custom_color_cool_bars", "type": "color", - "messageKey": "CLAY_BAR_COOL_COLOR", + "messageKey": "CLAY_COLOR_BAR_COOL", "defaultValue": "0000aa", "label": "Bar cold/full color", "sunlight": false, @@ -140,7 +140,7 @@ module.exports = [ { "id": "custom_color_hot_bars", "type": "color", - "messageKey": "CLAY_BAR_HOT_COLOR", + "messageKey": "CLAY_COLOR_BAR_HOT", "defaultValue": "ff0000", "label": "Bar hot/empty color", "sunlight": false, @@ -148,23 +148,39 @@ module.exports = [ { "id": "custom_color_mg_time", "type": "color", - "messageKey": "CLAY_TIME_MG_COLOR", + "messageKey": "CLAY_COLOR_TIME_MG", "defaultValue": "555555", "label": "Time segment midground color", "sunlight": false, }, { - "id": "custom_color_fg", + "id": "custom_color_letters", "type": "color", - "messageKey": "CLAY_FG_COLOR", + "messageKey": "CLAY_COLOR_LETTERS", "defaultValue": "ffffff", - "label": "Foreground color", + "label": "Letters (C/H/E/F) color", + "sunlight": false, + }, + { + "id": "custom_color_hours", + "type": "color", + "messageKey": "CLAY_COLOR_HOURS", + "defaultValue": "ffffff", + "label": "Hours color", + "sunlight": false, + }, + { + "id": "custom_color_minutes", + "type": "color", + "messageKey": "CLAY_COLOR_MINUTES", + "defaultValue": "ffffff", + "label": "Minutes color", "sunlight": false, }, { "id": "custom_color_warning", "type": "color", - "messageKey": "CLAY_WARNING_COLOR", + "messageKey": "CLAY_COLOR_WARNING", "defaultValue": "ffaa00", "label": "Warning indicator color", "sunlight": false, diff --git a/src/pkjs/customClay.js b/src/pkjs/customClay.js index 039c745..7fb0426 100644 --- a/src/pkjs/customClay.js +++ b/src/pkjs/customClay.js @@ -24,7 +24,9 @@ module.exports = function (minified) { clayConfig.getItemById('custom_color_cool_bars').set('0000aa'); clayConfig.getItemById('custom_color_hot_bars').set('ff0000'); clayConfig.getItemById('custom_color_mg_time').set('555555'); - clayConfig.getItemById('custom_color_fg').set('ff0000'); + clayConfig.getItemById('custom_color_letters').set('ff0000'); + clayConfig.getItemById('custom_color_hours').set('ff0000'); + clayConfig.getItemById('custom_color_minutes').set('ff0000'); clayConfig.getItemById('custom_color_warning').set('ffaa00'); break default: @@ -35,7 +37,9 @@ module.exports = function (minified) { clayConfig.getItemById('custom_color_cool_bars').set('0000aa'); clayConfig.getItemById('custom_color_hot_bars').set('ff0000'); clayConfig.getItemById('custom_color_mg_time').set('555555'); - clayConfig.getItemById('custom_color_fg').set('ffffff'); + clayConfig.getItemById('custom_color_letters').set('ffffff'); + clayConfig.getItemById('custom_color_hours').set('ffffff'); + clayConfig.getItemById('custom_color_minutes').set('ffffff'); clayConfig.getItemById('custom_color_warning').set('ffaa00'); } } @@ -50,7 +54,9 @@ module.exports = function (minified) { clayConfig.getItemById('custom_color_cool_bars').show(); clayConfig.getItemById('custom_color_hot_bars').show(); clayConfig.getItemById('custom_color_mg_time').show(); - clayConfig.getItemById('custom_color_fg').show(); + clayConfig.getItemById('custom_color_letters').show(); + clayConfig.getItemById('custom_color_hours').show(); + clayConfig.getItemById('custom_color_minutes').show(); clayConfig.getItemById('custom_color_warning').show(); } else { setColorsToPreset(); @@ -62,7 +68,9 @@ module.exports = function (minified) { clayConfig.getItemById('custom_color_cool_bars').hide(); clayConfig.getItemById('custom_color_hot_bars').hide(); clayConfig.getItemById('custom_color_mg_time').hide(); - clayConfig.getItemById('custom_color_fg').hide(); + clayConfig.getItemById('custom_color_letters').hide(); + clayConfig.getItemById('custom_color_hours').hide(); + clayConfig.getItemById('custom_color_minutes').hide(); clayConfig.getItemById('custom_color_warning').hide(); } }