diff options
| -rw-r--r-- | keyboards/converter/usb_usb/custom_matrix.cpp | 2 | ||||
| -rw-r--r-- | keyboards/sirius/unigo66/custom_matrix.cpp | 2 | ||||
| -rw-r--r-- | quantum/keyboard.c | 26 | ||||
| -rw-r--r-- | quantum/keyboard.h | 2 | ||||
| -rw-r--r-- | quantum/led.c | 44 | ||||
| -rw-r--r-- | quantum/led.h | 12 | ||||
| -rw-r--r-- | quantum/quantum.c | 11 | ||||
| -rw-r--r-- | quantum/quantum.h | 5 |
8 files changed, 58 insertions, 46 deletions
diff --git a/keyboards/converter/usb_usb/custom_matrix.cpp b/keyboards/converter/usb_usb/custom_matrix.cpp index 91986f6eb9..265fb2c68d 100644 --- a/keyboards/converter/usb_usb/custom_matrix.cpp +++ b/keyboards/converter/usb_usb/custom_matrix.cpp | |||
| @@ -185,7 +185,7 @@ extern "C" | |||
| 185 | // restore LED state when keyboard comes up | 185 | // restore LED state when keyboard comes up |
| 186 | if (usb_state == USB_STATE_RUNNING) { | 186 | if (usb_state == USB_STATE_RUNNING) { |
| 187 | dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low"); | 187 | dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low"); |
| 188 | keyboard_set_leds(host_keyboard_leds()); | 188 | led_set(host_keyboard_leds()); |
| 189 | } | 189 | } |
| 190 | } | 190 | } |
| 191 | matrix_scan_quantum(); | 191 | matrix_scan_quantum(); |
diff --git a/keyboards/sirius/unigo66/custom_matrix.cpp b/keyboards/sirius/unigo66/custom_matrix.cpp index dfcf82c779..955ce189a8 100644 --- a/keyboards/sirius/unigo66/custom_matrix.cpp +++ b/keyboards/sirius/unigo66/custom_matrix.cpp | |||
| @@ -166,7 +166,7 @@ extern "C" | |||
| 166 | // restore LED state when keyboard comes up | 166 | // restore LED state when keyboard comes up |
| 167 | if (usb_state == USB_STATE_RUNNING) { | 167 | if (usb_state == USB_STATE_RUNNING) { |
| 168 | dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low"); | 168 | dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low"); |
| 169 | keyboard_set_leds(host_keyboard_leds()); | 169 | led_set(host_keyboard_leds()); |
| 170 | } | 170 | } |
| 171 | } | 171 | } |
| 172 | return 1; | 172 | return 1; |
diff --git a/quantum/keyboard.c b/quantum/keyboard.c index fa20c675c3..60f5afb7a2 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c | |||
| @@ -350,32 +350,6 @@ void keyboard_init(void) { | |||
| 350 | keyboard_post_init_kb(); /* Always keep this last */ | 350 | keyboard_post_init_kb(); /* Always keep this last */ |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | /** \brief keyboard set leds | ||
| 354 | * | ||
| 355 | * FIXME: needs doc | ||
| 356 | */ | ||
| 357 | void keyboard_set_leds(uint8_t leds) { | ||
| 358 | if (debug_keyboard) { | ||
| 359 | debug("keyboard_set_led: "); | ||
| 360 | debug_hex8(leds); | ||
| 361 | debug("\n"); | ||
| 362 | } | ||
| 363 | led_set(leds); | ||
| 364 | } | ||
| 365 | |||
| 366 | /** \brief set host led state | ||
| 367 | * | ||
| 368 | * Only sets state if change detected | ||
| 369 | */ | ||
| 370 | void led_task(void) { | ||
| 371 | static uint8_t led_status = 0; | ||
| 372 | // update LED | ||
| 373 | if (led_status != host_keyboard_leds()) { | ||
| 374 | led_status = host_keyboard_leds(); | ||
| 375 | keyboard_set_leds(led_status); | ||
| 376 | } | ||
| 377 | } | ||
| 378 | |||
| 379 | /** \brief key_event_task | 353 | /** \brief key_event_task |
| 380 | * | 354 | * |
| 381 | * This function is responsible for calling into other systems when they need to respond to electrical switch press events. | 355 | * This function is responsible for calling into other systems when they need to respond to electrical switch press events. |
diff --git a/quantum/keyboard.h b/quantum/keyboard.h index 08f4e84f94..9b0fb3cef8 100644 --- a/quantum/keyboard.h +++ b/quantum/keyboard.h | |||
| @@ -58,8 +58,6 @@ void keyboard_setup(void); | |||
| 58 | void keyboard_init(void); | 58 | void keyboard_init(void); |
| 59 | /* it runs repeatedly in main loop */ | 59 | /* it runs repeatedly in main loop */ |
| 60 | void keyboard_task(void); | 60 | void keyboard_task(void); |
| 61 | /* it runs when host LED status is updated */ | ||
| 62 | void keyboard_set_leds(uint8_t leds); | ||
| 63 | /* it runs whenever code has to behave differently on a slave */ | 61 | /* it runs whenever code has to behave differently on a slave */ |
| 64 | bool is_keyboard_master(void); | 62 | bool is_keyboard_master(void); |
| 65 | /* it runs whenever code has to behave differently on left vs right split */ | 63 | /* it runs whenever code has to behave differently on left vs right split */ |
diff --git a/quantum/led.c b/quantum/led.c index 8f0eccf55d..7ee67b55e6 100644 --- a/quantum/led.c +++ b/quantum/led.c | |||
| @@ -13,13 +13,15 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #include "quantum.h" | 16 | #include "led.h" |
| 17 | #include "host.h" | ||
| 18 | #include "debug.h" | ||
| 17 | 19 | ||
| 18 | #ifdef BACKLIGHT_ENABLE | 20 | #ifdef BACKLIGHT_ENABLE |
| 19 | # include "backlight.h" | 21 | # include "backlight.h" |
| 20 | extern backlight_config_t backlight_config; | 22 | extern backlight_config_t backlight_config; |
| 21 | #else | 23 | #else |
| 22 | // Cannot use BACKLIGHT_CAPS_LOCK without backlight being enabled | 24 | # pragma message "Cannot use BACKLIGHT_CAPS_LOCK without backlight being enabled" |
| 23 | # undef BACKLIGHT_CAPS_LOCK | 25 | # undef BACKLIGHT_CAPS_LOCK |
| 24 | #endif | 26 | #endif |
| 25 | 27 | ||
| @@ -135,3 +137,41 @@ __attribute__((weak)) void led_set(uint8_t usb_led) { | |||
| 135 | led_set_kb(usb_led); | 137 | led_set_kb(usb_led); |
| 136 | led_update_kb((led_t)usb_led); | 138 | led_update_kb((led_t)usb_led); |
| 137 | } | 139 | } |
| 140 | |||
| 141 | /** \brief Trigger behaviour on transition to suspend | ||
| 142 | */ | ||
| 143 | void led_suspend(void) { | ||
| 144 | uint8_t leds_off = 0; | ||
| 145 | #ifdef BACKLIGHT_CAPS_LOCK | ||
| 146 | if (is_backlight_enabled()) { | ||
| 147 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 148 | leds_off |= (1 << USB_LED_CAPS_LOCK); | ||
| 149 | } | ||
| 150 | #endif | ||
| 151 | led_set(leds_off); | ||
| 152 | } | ||
| 153 | |||
| 154 | /** \brief Trigger behaviour on transition from suspend | ||
| 155 | */ | ||
| 156 | void led_wakeup(void) { led_set(host_keyboard_leds()); } | ||
| 157 | |||
| 158 | /** \brief set host led state | ||
| 159 | * | ||
| 160 | * Only sets state if change detected | ||
| 161 | */ | ||
| 162 | void led_task(void) { | ||
| 163 | static uint8_t last_led_status = 0; | ||
| 164 | |||
| 165 | // update LED | ||
| 166 | uint8_t led_status = host_keyboard_leds(); | ||
| 167 | if (last_led_status != led_status) { | ||
| 168 | last_led_status = led_status; | ||
| 169 | |||
| 170 | if (debug_keyboard) { | ||
| 171 | debug("led_task: "); | ||
| 172 | debug_hex8(led_status); | ||
| 173 | debug("\n"); | ||
| 174 | } | ||
| 175 | led_set(led_status); | ||
| 176 | } | ||
| 177 | } | ||
diff --git a/quantum/led.h b/quantum/led.h index 0fe38ea035..934d25312c 100644 --- a/quantum/led.h +++ b/quantum/led.h | |||
| @@ -49,6 +49,18 @@ void led_set(uint8_t usb_led); | |||
| 49 | 49 | ||
| 50 | void led_init_ports(void); | 50 | void led_init_ports(void); |
| 51 | 51 | ||
| 52 | void led_suspend(void); | ||
| 53 | |||
| 54 | void led_wakeup(void); | ||
| 55 | |||
| 56 | void led_task(void); | ||
| 57 | |||
| 58 | /* Callbacks */ | ||
| 59 | void led_set_user(uint8_t usb_led); | ||
| 60 | void led_set_kb(uint8_t usb_led); | ||
| 61 | bool led_update_user(led_t led_state); | ||
| 62 | bool led_update_kb(led_t led_state); | ||
| 63 | |||
| 52 | #ifdef __cplusplus | 64 | #ifdef __cplusplus |
| 53 | } | 65 | } |
| 54 | #endif | 66 | #endif |
diff --git a/quantum/quantum.c b/quantum/quantum.c index f12b1a9526..b59fcc9857 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -433,14 +433,7 @@ void suspend_power_down_quantum(void) { | |||
| 433 | # endif | 433 | # endif |
| 434 | 434 | ||
| 435 | // Turn off LED indicators | 435 | // Turn off LED indicators |
| 436 | uint8_t leds_off = 0; | 436 | led_suspend(); |
| 437 | # if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) | ||
| 438 | if (is_backlight_enabled()) { | ||
| 439 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 440 | leds_off |= (1 << USB_LED_CAPS_LOCK); | ||
| 441 | } | ||
| 442 | # endif | ||
| 443 | led_set(leds_off); | ||
| 444 | 437 | ||
| 445 | // Turn off audio | 438 | // Turn off audio |
| 446 | # ifdef AUDIO_ENABLE | 439 | # ifdef AUDIO_ENABLE |
| @@ -491,7 +484,7 @@ __attribute__((weak)) void suspend_wakeup_init_quantum(void) { | |||
| 491 | #endif | 484 | #endif |
| 492 | 485 | ||
| 493 | // Restore LED indicators | 486 | // Restore LED indicators |
| 494 | led_set(host_keyboard_leds()); | 487 | led_wakeup(); |
| 495 | 488 | ||
| 496 | // Wake up underglow | 489 | // Wake up underglow |
| 497 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 490 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 5d3a665887..020e455941 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -249,11 +249,6 @@ void register_code16(uint16_t code); | |||
| 249 | void unregister_code16(uint16_t code); | 249 | void unregister_code16(uint16_t code); |
| 250 | void tap_code16(uint16_t code); | 250 | void tap_code16(uint16_t code); |
| 251 | 251 | ||
| 252 | void led_set_user(uint8_t usb_led); | ||
| 253 | void led_set_kb(uint8_t usb_led); | ||
| 254 | bool led_update_user(led_t led_state); | ||
| 255 | bool led_update_kb(led_t led_state); | ||
| 256 | |||
| 257 | const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad); | 252 | const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad); |
| 258 | const char *get_u8_str(uint8_t curr_num, char curr_pad); | 253 | const char *get_u8_str(uint8_t curr_num, char curr_pad); |
| 259 | const char *get_u16_str(uint16_t curr_num, char curr_pad); | 254 | const char *get_u16_str(uint16_t curr_num, char curr_pad); |
