From 89fdafc27d2dc8652886950655352ce8628a5d57 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 9 Dec 2022 03:32:47 +0000 Subject: [PATCH] Refactor use of led_set_user within handwired/prime_exl (#19274) --- keyboards/handwired/prime_exl/config.h | 4 ++ .../prime_exl/keymaps/default/keymap.c | 42 +++--------------- .../handwired/prime_exl/keymaps/via/keymap.c | 43 +++---------------- 3 files changed, 18 insertions(+), 71 deletions(-) diff --git a/keyboards/handwired/prime_exl/config.h b/keyboards/handwired/prime_exl/config.h index 88919b934e374b02666eb2640a75dee4ea2298c2..37f514fc088be6499ae479a66fd8a0359bd83530 100644 --- a/keyboards/handwired/prime_exl/config.h +++ b/keyboards/handwired/prime_exl/config.h @@ -40,3 +40,7 @@ along with this program. If not, see . #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE + +#define NUM_LOCK_LED_PIN B6 +#define CAPS_LOCK_LED_PIN B5 +#define SCROLL_LOCK_LED_PIN C6 diff --git a/keyboards/handwired/prime_exl/keymaps/default/keymap.c b/keyboards/handwired/prime_exl/keymaps/default/keymap.c index 7cd3b6969e3cd6cb7c791fa8f962d1379c6bd1c5..260b8877043a5c80d902e8a5fb3e425ef0ccc1cc 100644 --- a/keyboards/handwired/prime_exl/keymaps/default/keymap.c +++ b/keyboards/handwired/prime_exl/keymaps/default/keymap.c @@ -94,45 +94,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } -void matrix_init_user(void) { - // set CapsLock LED to output and low - setPinOutput(C6); - writePinHigh(C6); - // set NumLock LED to output and low - setPinOutput(B6); - writePinHigh(B6); - // set ScrollLock LED to output and low - setPinOutput(B5); - writePinHigh(B5); -} - -void led_set_user(uint8_t usb_led) { - if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { - writePinHigh(B6); - } else { - writePinLow(B6); - } - if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { - writePinHigh(B5); - } else { - writePinLow(B5); - } - /* - if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) { - writePinHigh(C6); - } else { - writePinLow(C6); - } - */ +bool led_update_user(led_t led_state) { + writePin(NUM_LOCK_LED_PIN, led_state.num_lock); + writePin(CAPS_LOCK_LED_PIN, led_state.caps_lock); + // writePin(SCROLL_LOCK_LED_PIN, led_state.scroll_lock); + return false; } //function for layer indicator LED layer_state_t layer_state_set_user(layer_state_t state) { - if (get_highest_layer(state) == 2) { - writePinHigh(C6); - } else { - writePinLow(C6); - } + writePin(SCROLL_LOCK_LED_PIN, (get_highest_layer(state) == 1)); + return state; } diff --git a/keyboards/handwired/prime_exl/keymaps/via/keymap.c b/keyboards/handwired/prime_exl/keymaps/via/keymap.c index 1ff324102907118ff045924c4d30759318c03bd2..2081d672de05703acb6e3fb5f4a8dab41b850ee1 100644 --- a/keyboards/handwired/prime_exl/keymaps/via/keymap.c +++ b/keyboards/handwired/prime_exl/keymaps/via/keymap.c @@ -51,46 +51,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; - -void matrix_init_user(void) { - // set CapsLock LED to output and low - setPinOutput(C6); - writePinHigh(C6); - // set NumLock LED to output and low - setPinOutput(B6); - writePinHigh(B6); - // set ScrollLock LED to output and low - setPinOutput(B5); - writePinHigh(B5); -} - -void led_set_user(uint8_t usb_led) { - if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { - writePinHigh(B6); - } else { - writePinLow(B6); - } - if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { - writePinHigh(B5); - } else { - writePinLow(B5); - } - /* - if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) { - writePinHigh(C6); - } else { - writePinLow(C6); - } - */ +bool led_update_user(led_t led_state) { + writePin(NUM_LOCK_LED_PIN, led_state.num_lock); + writePin(CAPS_LOCK_LED_PIN, led_state.caps_lock); + // writePin(SCROLL_LOCK_LED_PIN, led_state.scroll_lock); + return false; } //function for layer indicator LED layer_state_t layer_state_set_user(layer_state_t state) { - if (get_highest_layer(state) == 1) { - writePinHigh(C6); - } else { - writePinLow(C6); - } + writePin(SCROLL_LOCK_LED_PIN, (get_highest_layer(state) == 1)); + return state; }