Skip to content

Commit

Permalink
added numlock led support. when numlock is off, led will be red
Browse files Browse the repository at this point in the history
  • Loading branch information
revulent committed Mar 10, 2024
1 parent 4c464a9 commit 5524731
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions keyboards/keychron/v5/ansi_encoder/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@

/* Enable caps-lock LED */
#define CAPS_LOCK_LED_INDEX 52
#define NUM_LOCK_LED_INDEX 31

#define TAPPING_TOGGLE 2
23 changes: 17 additions & 6 deletions keyboards/keychron/v5/v5.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ bool dip_switch_update_kb(uint8_t index, bool active) {
return true;
}

#endif // DIP_SWITCH_ENABLE
#endif // DIP_SWITCH_ENABLE

#if defined(RGB_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX)

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) { return false; }
if (!process_record_user(keycode, record)) {
return false;
}
switch (keycode) {
#ifdef RGB_MATRIX_ENABLE
# ifdef RGB_MATRIX_ENABLE
case RGB_TOG:
if (record->event.pressed) {
switch (rgb_matrix_get_flags()) {
Expand All @@ -53,20 +55,29 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
rgb_matrix_enable();
}
return false;
#endif
# endif
}
return true;
}

bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) { return false; }
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
return false;
}
// RGB_MATRIX_INDICATOR_SET_COLOR(index, red, green, blue);

if (host_keyboard_led_state().caps_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_LED_INDEX, 255, 255, 255);
} else {
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_LED_INDEX, 0, 0, 0);
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_LED_INDEX, 0, 0, 0);
}
}
if (!host_keyboard_led_state().num_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(NUM_LOCK_LED_INDEX, 255, 0, 0);
} else {
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(NUM_LOCK_LED_INDEX, 0, 0, 0);
}
}
return true;
Expand Down

0 comments on commit 5524731

Please sign in to comment.