summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/converter/usb_usb/custom_matrix.cpp2
-rw-r--r--keyboards/sirius/unigo66/custom_matrix.cpp2
-rw-r--r--quantum/keyboard.c26
-rw-r--r--quantum/keyboard.h2
-rw-r--r--quantum/led.c44
-rw-r--r--quantum/led.h12
-rw-r--r--quantum/quantum.c11
-rw-r--r--quantum/quantum.h5
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"
// restore LED state when keyboard comes up
if (usb_state == USB_STATE_RUNNING) {
dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low");
- keyboard_set_leds(host_keyboard_leds());
+ led_set(host_keyboard_leds());
}
}
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"
// restore LED state when keyboard comes up
if (usb_state == USB_STATE_RUNNING) {
dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low");
- keyboard_set_leds(host_keyboard_leds());
+ led_set(host_keyboard_leds());
}
}
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) {
keyboard_post_init_kb(); /* Always keep this last */
}
-/** \brief keyboard set leds
- *
- * FIXME: needs doc
- */
-void keyboard_set_leds(uint8_t leds) {
- if (debug_keyboard) {
- debug("keyboard_set_led: ");
- debug_hex8(leds);
- debug("\n");
- }
- led_set(leds);
-}
-
-/** \brief set host led state
- *
- * Only sets state if change detected
- */
-void led_task(void) {
- static uint8_t led_status = 0;
- // update LED
- if (led_status != host_keyboard_leds()) {
- led_status = host_keyboard_leds();
- keyboard_set_leds(led_status);
- }
-}
-
/** \brief key_event_task
*
* 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);
void keyboard_init(void);
/* it runs repeatedly in main loop */
void keyboard_task(void);
-/* it runs when host LED status is updated */
-void keyboard_set_leds(uint8_t leds);
/* it runs whenever code has to behave differently on a slave */
bool is_keyboard_master(void);
/* 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 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "quantum.h"
+#include "led.h"
+#include "host.h"
+#include "debug.h"
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
extern backlight_config_t backlight_config;
#else
-// Cannot use BACKLIGHT_CAPS_LOCK without backlight being enabled
+# pragma message "Cannot use BACKLIGHT_CAPS_LOCK without backlight being enabled"
# undef BACKLIGHT_CAPS_LOCK
#endif
@@ -135,3 +137,41 @@ __attribute__((weak)) void led_set(uint8_t usb_led) {
led_set_kb(usb_led);
led_update_kb((led_t)usb_led);
}
+
+/** \brief Trigger behaviour on transition to suspend
+ */
+void led_suspend(void) {
+ uint8_t leds_off = 0;
+#ifdef BACKLIGHT_CAPS_LOCK
+ if (is_backlight_enabled()) {
+ // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
+ leds_off |= (1 << USB_LED_CAPS_LOCK);
+ }
+#endif
+ led_set(leds_off);
+}
+
+/** \brief Trigger behaviour on transition from suspend
+ */
+void led_wakeup(void) { led_set(host_keyboard_leds()); }
+
+/** \brief set host led state
+ *
+ * Only sets state if change detected
+ */
+void led_task(void) {
+ static uint8_t last_led_status = 0;
+
+ // update LED
+ uint8_t led_status = host_keyboard_leds();
+ if (last_led_status != led_status) {
+ last_led_status = led_status;
+
+ if (debug_keyboard) {
+ debug("led_task: ");
+ debug_hex8(led_status);
+ debug("\n");
+ }
+ led_set(led_status);
+ }
+}
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);
void led_init_ports(void);
+void led_suspend(void);
+
+void led_wakeup(void);
+
+void led_task(void);
+
+/* Callbacks */
+void led_set_user(uint8_t usb_led);
+void led_set_kb(uint8_t usb_led);
+bool led_update_user(led_t led_state);
+bool led_update_kb(led_t led_state);
+
#ifdef __cplusplus
}
#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) {
# endif
// Turn off LED indicators
- uint8_t leds_off = 0;
-# if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
- if (is_backlight_enabled()) {
- // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
- leds_off |= (1 << USB_LED_CAPS_LOCK);
- }
-# endif
- led_set(leds_off);
+ led_suspend();
// Turn off audio
# ifdef AUDIO_ENABLE
@@ -491,7 +484,7 @@ __attribute__((weak)) void suspend_wakeup_init_quantum(void) {
#endif
// Restore LED indicators
- led_set(host_keyboard_leds());
+ led_wakeup();
// Wake up underglow
#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);
void unregister_code16(uint16_t code);
void tap_code16(uint16_t code);
-void led_set_user(uint8_t usb_led);
-void led_set_kb(uint8_t usb_led);
-bool led_update_user(led_t led_state);
-bool led_update_kb(led_t led_state);
-
const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad);
const char *get_u8_str(uint8_t curr_num, char curr_pad);
const char *get_u16_str(uint16_t curr_num, char curr_pad);