summaryrefslogtreecommitdiff
path: root/quantum/led.c
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas@t-8ch.de>2022-10-06 12:24:41 +0200
committerGitHub <noreply@github.com>2022-10-06 21:24:41 +1100
commitcbe1c22d468d64d7a3274061ce9c2073ecb208a4 (patch)
tree00fea20653a9bb57af68c9a5c873f3c4a1874ecd /quantum/led.c
parentc255174cf3e55483f14351a69689e24e849445a0 (diff)
quantum: led: split out led_update_ports() for customization of led behaviour (#14452)
Diffstat (limited to 'quantum/led.c')
-rw-r--r--quantum/led.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/quantum/led.c b/quantum/led.c
index 444d38f751..7db38bb88c 100644
--- a/quantum/led.c
+++ b/quantum/led.c
@@ -92,32 +92,36 @@ __attribute__((weak)) bool led_update_user(led_t led_state) {
__attribute__((weak)) bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
-#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN)
-# if LED_PIN_ON_STATE == 0
- // invert the whole thing to avoid having to conditionally !led_state.x later
- led_state.raw = ~led_state.raw;
-# endif
-
-# ifdef LED_NUM_LOCK_PIN
- writePin(LED_NUM_LOCK_PIN, led_state.num_lock);
-# endif
-# ifdef LED_CAPS_LOCK_PIN
- writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock);
-# endif
-# ifdef LED_SCROLL_LOCK_PIN
- writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock);
-# endif
-# ifdef LED_COMPOSE_PIN
- writePin(LED_COMPOSE_PIN, led_state.compose);
-# endif
-# ifdef LED_KANA_PIN
- writePin(LED_KANA_PIN, led_state.kana);
-# endif
-#endif
+ led_update_ports(led_state);
}
return res;
}
+/** \brief Write LED state to hardware
+ */
+__attribute__((weak)) void led_update_ports(led_t led_state) {
+#if LED_PIN_ON_STATE == 0
+ // invert the whole thing to avoid having to conditionally !led_state.x later
+ led_state.raw = ~led_state.raw;
+#endif
+
+#ifdef LED_NUM_LOCK_PIN
+ writePin(LED_NUM_LOCK_PIN, led_state.num_lock);
+#endif
+#ifdef LED_CAPS_LOCK_PIN
+ writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock);
+#endif
+#ifdef LED_SCROLL_LOCK_PIN
+ writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock);
+#endif
+#ifdef LED_COMPOSE_PIN
+ writePin(LED_COMPOSE_PIN, led_state.compose);
+#endif
+#ifdef LED_KANA_PIN
+ writePin(LED_KANA_PIN, led_state.kana);
+#endif
+}
+
/** \brief Initialise any LED related hardware and/or state
*/
__attribute__((weak)) void led_init_ports(void) {