diff --git a/device/src/main.c b/device/src/main.c index 5a35ca83..7319f554 100644 --- a/device/src/main.c +++ b/device/src/main.c @@ -126,7 +126,6 @@ int main(void) { } if (DEVICE_IS_UHK80_LEFT || DEVICE_IS_UHK80_RIGHT) { - ConfigManager_ResetConfiguration(false); Ledmap_InitLedLayout(); } @@ -148,6 +147,10 @@ int main(void) { Macros_Initialize(); } + if (DEVICE_IS_UHK80_LEFT) { + UsbCommand_ApplyFactory(); + } + USB_EnableHid(); // has to be after USB_SetSerialNumber bt_enable(NULL); diff --git a/right/src/config_parser/parse_config.c b/right/src/config_parser/parse_config.c index 6fa61df7..692fa768 100644 --- a/right/src/config_parser/parse_config.c +++ b/right/src/config_parser/parse_config.c @@ -327,6 +327,7 @@ parser_error_t parseConfig(config_buffer_t *buffer) Cfg.KeyBacklightFadeOutTimeout = keyBacklightFadeOutTimeout; Cfg.KeyBacklightFadeOutBatteryTimeout = keyBacklightFadeOutBatteryTimeout; + AlwaysOnMode = false; LedManager_RecalculateLedBrightness(); LedManager_UpdateSleepModes(); BtPair_ClearUnknownBonds(); diff --git a/right/src/led_manager.c b/right/src/led_manager.c index b1b284ea..cfd5016c 100644 --- a/right/src/led_manager.c +++ b/right/src/led_manager.c @@ -23,18 +23,20 @@ bool DisplaySleepModeActive = false; uint8_t DisplayBrightness = 0xff; uint8_t KeyBacklightBrightness = 0xff; +bool AlwaysOnMode = false; + static void recalculateLedBrightness() { bool globalSleepMode = !Cfg.LedsEnabled || CurrentPowerMode > PowerMode_Awake || Cfg.LedBrightnessMultiplier == 0.0f; - if (globalSleepMode || KeyBacklightSleepModeActive) { + if (!AlwaysOnMode && (globalSleepMode || KeyBacklightSleepModeActive)) { KeyBacklightBrightness = 0; } else { uint8_t keyBacklightBrightnessBase = RunningOnBattery ? Cfg.KeyBacklightBrightnessBatteryDefault : Cfg.KeyBacklightBrightnessDefault; KeyBacklightBrightness = MIN(255, keyBacklightBrightnessBase * Cfg.LedBrightnessMultiplier); } - if (globalSleepMode || DisplaySleepModeActive) { + if (!AlwaysOnMode && (globalSleepMode || DisplaySleepModeActive)) { DisplayBrightness = 0; } else { uint8_t displayBrightnessBase = RunningOnBattery ? Cfg.DisplayBrightnessBatteryDefault : Cfg.DisplayBrightnessDefault; diff --git a/right/src/led_manager.h b/right/src/led_manager.h index b8bdf01e..eb626e96 100644 --- a/right/src/led_manager.h +++ b/right/src/led_manager.h @@ -16,6 +16,8 @@ extern bool KeyBacklightSleepModeActive; extern bool DisplaySleepModeActive; + extern bool AlwaysOnMode; + // Functions: void LedManager_FullUpdate(); diff --git a/right/src/ledmap.c b/right/src/ledmap.c index 2898435e..451a3610 100644 --- a/right/src/ledmap.c +++ b/right/src/ledmap.c @@ -591,6 +591,22 @@ static void updateLedsByLedTestStragegy() { } } +static void updateLedsByLightAllStragegy() { +#ifdef __ZEPHYR__ +#if DEVICE_IS_UHK80_LEFT || DEVICE_IS_UHK80_RIGHT + for (uint8_t i = 0; i < UHK80_LED_DRIVER_LED_COUNT_MAX; i++) { + Uhk80LedDriverValues[i] = 255; + } +#endif +#else + for (uint8_t slotId=0; slotId +#include "ledmap.h" #include "usb_commands/usb_command_apply_config.h" #include "config_parser/config_globals.h" #include "config_parser/parse_config.h" @@ -45,6 +46,19 @@ void UsbCommand_ApplyConfigAsync(void) { } } +static void setLedsWhite() { + // Set the led test backlight mode, but don't activate the switch test mode. + Ledmap_SetLedBacklightingMode(BacklightingMode_LightAll); + AlwaysOnMode = true; + Cfg.KeyBacklightBrightnessDefault = 255; + Cfg.KeyBacklightBrightnessBatteryDefault = 255; + EventVector_Set(EventVector_LedMapUpdateNeeded); +} + +static bool hwConfigEmpty() { + return HardwareConfig->majorVersion == 0 || HardwareConfig->majorVersion == 255; +} + void UsbCommand_ApplyFactory(void) { EventVector_Unset(EventVector_ApplyConfig); @@ -55,6 +69,10 @@ void UsbCommand_ApplyFactory(void) ConfigManager_ResetConfiguration(false); + if (hwConfigEmpty()) { + setLedsWhite(); + } + #ifdef __ZEPHYR__ StateSync_ResetConfig(); StateSync_ResetRightLeftLink(true); @@ -107,6 +125,10 @@ uint8_t UsbCommand_ApplyConfig(void) MacroEvent_OnInit(); + if (hwConfigEmpty()) { + setLedsWhite(); + } + #ifdef __ZEPHYR__ StateSync_ResetConfig(); #endif diff --git a/shared/versioning.h b/shared/versioning.h index 26338af7..1431ce54 100644 --- a/shared/versioning.h +++ b/shared/versioning.h @@ -18,6 +18,9 @@ (((v).major > (MAJ)) || ((v).major == (MAJ) && (v).minor > (MIN)) || \ ((v).major == (MAJ) && (v).minor == (MIN) && (v).patch >= (PATCH))) +#define VERSION_EQUAL(v, MAJ, MIN, PATCH) \ + ((v).major == (MAJ) && (v).minor == (MIN) && (v).patch == (PATCH)) + // Typedefs: typedef struct {