From d4d08da553b9fca5cd8d86f5d0f3516a062922cf Mon Sep 17 00:00:00 2001 From: Vino Rodrigues <366673+vinorodrigues@users.noreply.github.com> Date: Sun, 30 Jan 2022 12:51:10 +1100 Subject: [PATCH] added caps-lock led to all other revs --- keyboards/keychron/q1/q1.c | 22 +++++++++++++++---- .../keychron/q1/q1_ansi_atmega32u4/config.h | 3 +++ .../q1/q1_ansi_atmega32u4_ec11/config.h | 3 +++ .../keychron/q1/q1_ansi_stm32l432/config.h | 3 +++ .../keychron/q1/q1_iso_atmega32u4/config.h | 5 ++++- .../q1/q1_iso_atmega32u4_ec11/config.h | 3 +++ .../keychron/q1/q1_iso_stm32l432/config.h | 3 +++ .../q1/q1_iso_stm32l432_ec11/config.h | 3 +++ 8 files changed, 40 insertions(+), 5 deletions(-) diff --git a/keyboards/keychron/q1/q1.c b/keyboards/keychron/q1/q1.c index aa0258901b15..ae134fe64ff9 100644 --- a/keyboards/keychron/q1/q1.c +++ b/keyboards/keychron/q1/q1.c @@ -32,16 +32,30 @@ bool dip_switch_update_kb(uint8_t index, bool active) { #if defined(RGB_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX) -#define CAPS_LOCK_BRIGHTNESS 0xFF +#define CAPS_LOCK_MAX_BRIGHTNESS 0xFF #ifdef RGB_MATRIX_MAXIMUM_BRIGHTNESS - #undef CAPS_LOCK_BRIGHTNESS - #define CAPS_LOCK_BRIGHTNESS RGB_MATRIX_MAXIMUM_BRIGHTNESS + #undef CAPS_LOCK_MAX_BRIGHTNESS + #define CAPS_LOCK_MAX_BRIGHTNESS RGB_MATRIX_MAXIMUM_BRIGHTNESS +#endif + +#define CAPS_LOCK_VAL_STEP 8 +#ifdef RGB_MATRIX_VAL_STEP + #undef CAPS_LOCK_VAL_STEP + #define CAPS_LOCK_VAL_STEP RGB_MATRIX_VAL_STEP #endif __attribute__((weak)) void rgb_matrix_indicators_user(void) { if (host_keyboard_led_state().caps_lock) { - rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, CAPS_LOCK_BRIGHTNESS, CAPS_LOCK_BRIGHTNESS, CAPS_LOCK_BRIGHTNESS); // white + uint8_t b = rgb_matrix_get_val(); + if (b < CAPS_LOCK_VAL_STEP) { + b = CAPS_LOCK_VAL_STEP; + } else if (b < (CAPS_LOCK_MAX_BRIGHTNESS - CAPS_LOCK_VAL_STEP)) { + b += CAPS_LOCK_VAL_STEP; // one step more than current brightness + } else { + b = CAPS_LOCK_MAX_BRIGHTNESS; + } + rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, b, b, b); // white, with the adjusted brightness } } diff --git a/keyboards/keychron/q1/q1_ansi_atmega32u4/config.h b/keyboards/keychron/q1/q1_ansi_atmega32u4/config.h index 391e07735801..2f5f769a8f48 100644 --- a/keyboards/keychron/q1/q1_ansi_atmega32u4/config.h +++ b/keyboards/keychron/q1/q1_ansi_atmega32u4/config.h @@ -40,3 +40,6 @@ #define DRIVER_1_LED_TOTAL 59 #define DRIVER_2_LED_TOTAL 23 #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) + +/* Enable caps-lock LED */ +#define CAPS_LOCK_LED_INDEX 45 diff --git a/keyboards/keychron/q1/q1_ansi_atmega32u4_ec11/config.h b/keyboards/keychron/q1/q1_ansi_atmega32u4_ec11/config.h index 0323b449babe..872604855f45 100644 --- a/keyboards/keychron/q1/q1_ansi_atmega32u4_ec11/config.h +++ b/keyboards/keychron/q1/q1_ansi_atmega32u4_ec11/config.h @@ -47,3 +47,6 @@ /* Specifies the number of pulses the encoder registers between each detent */ #define ENCODER_RESOLUTION 4 + +/* Enable caps-lock LED */ +#define CAPS_LOCK_LED_INDEX 45 diff --git a/keyboards/keychron/q1/q1_ansi_stm32l432/config.h b/keyboards/keychron/q1/q1_ansi_stm32l432/config.h index ecd1ac046522..1d81c2903301 100644 --- a/keyboards/keychron/q1/q1_ansi_stm32l432/config.h +++ b/keyboards/keychron/q1/q1_ansi_stm32l432/config.h @@ -52,3 +52,6 @@ /* We have 2KB EEPROM size on STM32L432 */ #define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 + +/* Enable caps-lock LED */ +#define CAPS_LOCK_LED_INDEX 45 diff --git a/keyboards/keychron/q1/q1_iso_atmega32u4/config.h b/keyboards/keychron/q1/q1_iso_atmega32u4/config.h index d7b04967805e..b81dc0005adf 100644 --- a/keyboards/keychron/q1/q1_iso_atmega32u4/config.h +++ b/keyboards/keychron/q1/q1_iso_atmega32u4/config.h @@ -39,4 +39,7 @@ /* RGB Matrix Configuration */ #define DRIVER_1_LED_TOTAL 59 #define DRIVER_2_LED_TOTAL 24 -#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) \ No newline at end of file +#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) + +/* Enable caps-lock LED */ +#define CAPS_LOCK_LED_INDEX 44 diff --git a/keyboards/keychron/q1/q1_iso_atmega32u4_ec11/config.h b/keyboards/keychron/q1/q1_iso_atmega32u4_ec11/config.h index 8fb24021b21c..e218f570717f 100644 --- a/keyboards/keychron/q1/q1_iso_atmega32u4_ec11/config.h +++ b/keyboards/keychron/q1/q1_iso_atmega32u4_ec11/config.h @@ -43,3 +43,6 @@ /* Specifies the number of pulses the encoder registers between each detent */ #define ENCODER_RESOLUTION 4 + +/* Enable caps-lock LED */ +#define CAPS_LOCK_LED_INDEX 44 diff --git a/keyboards/keychron/q1/q1_iso_stm32l432/config.h b/keyboards/keychron/q1/q1_iso_stm32l432/config.h index 47c42162d9b0..e4bde87bc15c 100644 --- a/keyboards/keychron/q1/q1_iso_stm32l432/config.h +++ b/keyboards/keychron/q1/q1_iso_stm32l432/config.h @@ -52,3 +52,6 @@ /* We have 2KB EEPROM size on STM32L432 */ #define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 + +/* Enable caps-lock LED */ +#define CAPS_LOCK_LED_INDEX 44 diff --git a/keyboards/keychron/q1/q1_iso_stm32l432_ec11/config.h b/keyboards/keychron/q1/q1_iso_stm32l432_ec11/config.h index 4c9260b9523a..59de237d148a 100644 --- a/keyboards/keychron/q1/q1_iso_stm32l432_ec11/config.h +++ b/keyboards/keychron/q1/q1_iso_stm32l432_ec11/config.h @@ -53,3 +53,6 @@ /* Specifies the number of pulses the encoder registers between each detent */ #define ENCODER_RESOLUTION 4 + +/* Enable caps-lock LED */ +#define CAPS_LOCK_LED_INDEX 44