Skip to content

Commit

Permalink
Merge pull request qmk#11 from keychron-contrib/vr-q1-caps-lock-led-all
Browse files Browse the repository at this point in the history
Added Caps-Lock LED to all other Q1 revs
  • Loading branch information
KeychronMacro authored Jan 31, 2022
2 parents ca65b2c + d4d08da commit b23f7f3
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
22 changes: 18 additions & 4 deletions keyboards/keychron/q1/q1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
3 changes: 3 additions & 0 deletions keyboards/keychron/q1/q1_ansi_atmega32u4/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions keyboards/keychron/q1/q1_ansi_atmega32u4_ec11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions keyboards/keychron/q1/q1_ansi_stm32l432/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion keyboards/keychron/q1/q1_iso_atmega32u4/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)

/* Enable caps-lock LED */
#define CAPS_LOCK_LED_INDEX 44
3 changes: 3 additions & 0 deletions keyboards/keychron/q1/q1_iso_atmega32u4_ec11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions keyboards/keychron/q1/q1_iso_stm32l432/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions keyboards/keychron/q1/q1_iso_stm32l432_ec11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b23f7f3

Please sign in to comment.