diff options
| author | Thomas Weißschuh <thomas@t-8ch.de> | 2022-10-06 12:24:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-06 21:24:41 +1100 |
| commit | cbe1c22d468d64d7a3274061ce9c2073ecb208a4 (patch) | |
| tree | 00fea20653a9bb57af68c9a5c873f3c4a1874ecd /quantum/led.c | |
| parent | c255174cf3e55483f14351a69689e24e849445a0 (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.c | 48 |
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) { | |||
| 92 | __attribute__((weak)) bool led_update_kb(led_t led_state) { | 92 | __attribute__((weak)) bool led_update_kb(led_t led_state) { |
| 93 | bool res = led_update_user(led_state); | 93 | bool res = led_update_user(led_state); |
| 94 | if (res) { | 94 | if (res) { |
| 95 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) | 95 | led_update_ports(led_state); |
| 96 | # if LED_PIN_ON_STATE == 0 | ||
| 97 | // invert the whole thing to avoid having to conditionally !led_state.x later | ||
| 98 | led_state.raw = ~led_state.raw; | ||
| 99 | # endif | ||
| 100 | |||
| 101 | # ifdef LED_NUM_LOCK_PIN | ||
| 102 | writePin(LED_NUM_LOCK_PIN, led_state.num_lock); | ||
| 103 | # endif | ||
| 104 | # ifdef LED_CAPS_LOCK_PIN | ||
| 105 | writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock); | ||
| 106 | # endif | ||
| 107 | # ifdef LED_SCROLL_LOCK_PIN | ||
| 108 | writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock); | ||
| 109 | # endif | ||
| 110 | # ifdef LED_COMPOSE_PIN | ||
| 111 | writePin(LED_COMPOSE_PIN, led_state.compose); | ||
| 112 | # endif | ||
| 113 | # ifdef LED_KANA_PIN | ||
| 114 | writePin(LED_KANA_PIN, led_state.kana); | ||
| 115 | # endif | ||
| 116 | #endif | ||
| 117 | } | 96 | } |
| 118 | return res; | 97 | return res; |
| 119 | } | 98 | } |
| 120 | 99 | ||
| 100 | /** \brief Write LED state to hardware | ||
| 101 | */ | ||
| 102 | __attribute__((weak)) void led_update_ports(led_t led_state) { | ||
| 103 | #if LED_PIN_ON_STATE == 0 | ||
| 104 | // invert the whole thing to avoid having to conditionally !led_state.x later | ||
| 105 | led_state.raw = ~led_state.raw; | ||
| 106 | #endif | ||
| 107 | |||
| 108 | #ifdef LED_NUM_LOCK_PIN | ||
| 109 | writePin(LED_NUM_LOCK_PIN, led_state.num_lock); | ||
| 110 | #endif | ||
| 111 | #ifdef LED_CAPS_LOCK_PIN | ||
| 112 | writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock); | ||
| 113 | #endif | ||
| 114 | #ifdef LED_SCROLL_LOCK_PIN | ||
| 115 | writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock); | ||
| 116 | #endif | ||
| 117 | #ifdef LED_COMPOSE_PIN | ||
| 118 | writePin(LED_COMPOSE_PIN, led_state.compose); | ||
| 119 | #endif | ||
| 120 | #ifdef LED_KANA_PIN | ||
| 121 | writePin(LED_KANA_PIN, led_state.kana); | ||
| 122 | #endif | ||
| 123 | } | ||
| 124 | |||
| 121 | /** \brief Initialise any LED related hardware and/or state | 125 | /** \brief Initialise any LED related hardware and/or state |
| 122 | */ | 126 | */ |
| 123 | __attribute__((weak)) void led_init_ports(void) { | 127 | __attribute__((weak)) void led_init_ports(void) { |
