diff --git a/right/src/config_parser/parse_config.c b/right/src/config_parser/parse_config.c index 86136fb..98e9608 100644 --- a/right/src/config_parser/parse_config.c +++ b/right/src/config_parser/parse_config.c @@ -5,6 +5,9 @@ #include "config_globals.h" #include "macros.h" #include "usb_report_updater.h" +#include "led_display.h" +#include "slave_scheduler.h" +#include "slave_drivers/is31fl3731_driver.h" static parser_error_t parseModuleConfiguration(config_buffer_t *buffer) { @@ -59,10 +62,6 @@ parser_error_t ParseConfig(config_buffer_t *buffer) uint8_t alphanumericSegmentsBrightness = ReadUInt8(buffer); uint8_t keyBacklightBrightness = ReadUInt8(buffer); - (void)iconsAndLayerTextsBrightness; - (void)alphanumericSegmentsBrightness; - (void)keyBacklightBrightness; - // Mouse kinetic properties uint8_t mouseMoveInitialSpeed = ReadUInt8(buffer); @@ -138,6 +137,16 @@ parser_error_t ParseConfig(config_buffer_t *buffer) if (!ParserRunDry) { DoubleTapSwitchLayerTimeout = doubleTapSwitchLayerTimeout; + // Update LED brightnesses and reinitialize LED drivers + + IconsAndLayerTextsBrightness = iconsAndLayerTextsBrightness; + AlphanumericSegmentsBrightness = alphanumericSegmentsBrightness; + KeyBacklightBrightness = keyBacklightBrightness; + Slaves[SlaveId_LeftLedDriver].isConnected = false; + Slaves[SlaveId_RightLedDriver].isConnected = false; + + // Update mouse key speeds + MouseMoveState.initialSpeed = mouseMoveInitialSpeed; MouseMoveState.acceleration = mouseMoveAcceleration; MouseMoveState.deceleratedSpeed = mouseMoveDeceleratedSpeed; @@ -150,6 +159,8 @@ parser_error_t ParseConfig(config_buffer_t *buffer) MouseScrollState.baseSpeed = mouseScrollBaseSpeed; MouseScrollState.acceleratedSpeed = mouseScrollAcceleratedSpeed; + // Update counts + AllKeymapsCount = keymapCount; AllMacrosCount = macroCount; } diff --git a/right/src/led_display.c b/right/src/led_display.c index 151dcb8..cb3d8c9 100644 --- a/right/src/led_display.c +++ b/right/src/led_display.c @@ -3,6 +3,9 @@ #include "layer.h" #include "keymap.h" +uint8_t IconsAndLayerTextsBrightness = 0xff; +uint8_t AlphanumericSegmentsBrightness = 0xff; + static const uint16_t capitalLetterToSegmentSet[] = { 0b0000000011110111, 0b0001001010001111, @@ -69,13 +72,13 @@ void LedDisplay_SetText(uint8_t length, const char* text) allSegmentSets |= characterToSegmentSet(text[0]); } - LedDriverValues[LedDriverId_Left][11] = allSegmentSets & 0b00000001 ? LED_BRIGHTNESS_LEVEL : 0; - LedDriverValues[LedDriverId_Left][12] = allSegmentSets & 0b00000010 ? LED_BRIGHTNESS_LEVEL : 0; + LedDriverValues[LedDriverId_Left][11] = allSegmentSets & 0b00000001 ? AlphanumericSegmentsBrightness : 0; + LedDriverValues[LedDriverId_Left][12] = allSegmentSets & 0b00000010 ? AlphanumericSegmentsBrightness : 0; allSegmentSets >>= 2; for (uint8_t i = 24; i <= 136; i += 16) { for (uint8_t j = 0; j < 5; j++) { - LedDriverValues[LedDriverId_Left][i + j] = allSegmentSets & 1 << j ? LED_BRIGHTNESS_LEVEL : 0; + LedDriverValues[LedDriverId_Left][i + j] = allSegmentSets & 1 << j ? AlphanumericSegmentsBrightness : 0; } allSegmentSets >>= 5; } @@ -94,11 +97,11 @@ void LedDisplay_SetLayer(uint8_t layerId) } if (layerId >= LayerId_Mod && layerId <= LayerId_Mouse) { - LedDriverValues[LedDriverId_Left][16 * layerId - 3] = LED_BRIGHTNESS_LEVEL; + LedDriverValues[LedDriverId_Left][16 * layerId - 3] = IconsAndLayerTextsBrightness; } } void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled) { - LedDriverValues[LedDriverId_Left][8 + icon] = isEnabled ? LED_BRIGHTNESS_LEVEL : 0; + LedDriverValues[LedDriverId_Left][8 + icon] = isEnabled ? IconsAndLayerTextsBrightness : 0; } diff --git a/right/src/led_display.h b/right/src/led_display.h index 48c53cb..8e76c23 100644 --- a/right/src/led_display.h +++ b/right/src/led_display.h @@ -14,6 +14,11 @@ LedDisplayIcon_Adaptive, } led_display_icon_t; +// Variables: + + extern uint8_t IconsAndLayerTextsBrightness; + extern uint8_t AlphanumericSegmentsBrightness; + // Functions: void LedDisplay_SetText(uint8_t length, const char* text); diff --git a/right/src/slave_drivers/is31fl3731_driver.c b/right/src/slave_drivers/is31fl3731_driver.c index 6454892..aae060f 100644 --- a/right/src/slave_drivers/is31fl3731_driver.c +++ b/right/src/slave_drivers/is31fl3731_driver.c @@ -3,6 +3,7 @@ #include "slave_scheduler.h" #include "led_display.h" +uint8_t KeyBacklightBrightness = 0xff; uint8_t LedDriverValues[LED_DRIVER_MAX_COUNT][LED_DRIVER_LED_COUNT]; static led_driver_state_t ledDriverStates[LED_DRIVER_MAX_COUNT] = { @@ -70,7 +71,7 @@ void LedSlaveDriver_Init(uint8_t ledDriverId) led_driver_state_t *currentLedDriverState = ledDriverStates + ledDriverId; currentLedDriverState->phase = LedDriverPhase_SetFunctionFrame; currentLedDriverState->ledIndex = 0; - memset(LedDriverValues[ledDriverId], LED_BRIGHTNESS_LEVEL, LED_DRIVER_LED_COUNT); + memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT); if (ledDriverId == LedDriverId_Left) { LedDisplay_SetIcon(LedDisplayIcon_CapsLock, false); diff --git a/right/src/slave_drivers/is31fl3731_driver.h b/right/src/slave_drivers/is31fl3731_driver.h index db97c43..8ae937a 100644 --- a/right/src/slave_drivers/is31fl3731_driver.h +++ b/right/src/slave_drivers/is31fl3731_driver.h @@ -12,7 +12,6 @@ #define LED_CONTROL_REGISTERS_COMMAND_LENGTH 19 #define PMW_REGISTER_UPDATE_CHUNK_SIZE 8 #define PWM_REGISTER_BUFFER_LENGTH (1 + PMW_REGISTER_UPDATE_CHUNK_SIZE) - #define LED_BRIGHTNESS_LEVEL 0xff #define IS_ISO true #define ISO_KEY_LED_DRIVER_ID LedDriverId_Left @@ -45,6 +44,7 @@ // Variables: + extern uint8_t KeyBacklightBrightness; extern uint8_t LedDriverValues[LED_DRIVER_MAX_COUNT][LED_DRIVER_LED_COUNT]; // Functions: