From 6e83b449409f7fe479210a9fab808e8bcae64977 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 22 Jan 2022 21:17:02 +0000 Subject: Align location of some host led logic (#15954) * Align location of host led logic * Move more * align ifdefs * Fix up includes * Move callback defs * Convert comment to build message --- quantum/led.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'quantum/led.c') 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 . */ -#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); + } +} -- cgit v1.2.3 From eddd1c05674ce48dd5db0d7da996a4da2ecd705a Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 22 Jan 2022 23:11:42 +0000 Subject: Fix BACKLIGHT_CAPS_LOCK warning (#15999) * Fix BACKLIGHT_CAPS_LOCK warning * align defs --- quantum/led.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'quantum/led.c') diff --git a/quantum/led.c b/quantum/led.c index 7ee67b55e6..68494af3c2 100644 --- a/quantum/led.c +++ b/quantum/led.c @@ -17,19 +17,21 @@ #include "host.h" #include "debug.h" -#ifdef BACKLIGHT_ENABLE -# include "backlight.h" +#ifdef BACKLIGHT_CAPS_LOCK +# ifdef BACKLIGHT_ENABLE +# include "backlight.h" extern backlight_config_t backlight_config; -#else -# pragma message "Cannot use BACKLIGHT_CAPS_LOCK without backlight being enabled" -# undef BACKLIGHT_CAPS_LOCK +# else +# pragma message "Cannot use BACKLIGHT_CAPS_LOCK without backlight being enabled" +# undef BACKLIGHT_CAPS_LOCK +# endif #endif #ifndef LED_PIN_ON_STATE # define LED_PIN_ON_STATE 1 #endif -#if defined(BACKLIGHT_CAPS_LOCK) +#ifdef BACKLIGHT_CAPS_LOCK /** \brief Caps Lock indicator using backlight (for keyboards without dedicated LED) */ static void handle_backlight_caps_lock(led_t led_state) { -- cgit v1.2.3 From 8101a836a410c54f14c4f61738bfedf5912e903e Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 22 Jan 2022 15:43:39 -0800 Subject: [Bug] Fix compilation issues for led indicators (#16001) --- quantum/led.c | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum/led.c') diff --git a/quantum/led.c b/quantum/led.c index 68494af3c2..7b3f877208 100644 --- a/quantum/led.c +++ b/quantum/led.c @@ -16,6 +16,7 @@ #include "led.h" #include "host.h" #include "debug.h" +#include "gpio.h" #ifdef BACKLIGHT_CAPS_LOCK # ifdef BACKLIGHT_ENABLE -- cgit v1.2.3 From 63646e8906e062d1c1de3925cba70c4e3426a855 Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Sat, 12 Feb 2022 10:29:31 -0800 Subject: Format code according to conventions (#16322) --- quantum/led.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'quantum/led.c') diff --git a/quantum/led.c b/quantum/led.c index 7b3f877208..c5ddbc22c5 100644 --- a/quantum/led.c +++ b/quantum/led.c @@ -64,13 +64,17 @@ __attribute__((weak)) void led_set_user(uint8_t usb_led) {} * * \deprecated Use led_update_kb() instead. */ -__attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } +__attribute__((weak)) void led_set_kb(uint8_t usb_led) { + led_set_user(usb_led); +} /** \brief Lock LED update callback - keymap/user level * * \return True if led_update_kb() should run its own code, false otherwise. */ -__attribute__((weak)) bool led_update_user(led_t led_state) { return true; } +__attribute__((weak)) bool led_update_user(led_t led_state) { + return true; +} /** \brief Lock LED update callback - keyboard level * @@ -156,7 +160,9 @@ void led_suspend(void) { /** \brief Trigger behaviour on transition from suspend */ -void led_wakeup(void) { led_set(host_keyboard_leds()); } +void led_wakeup(void) { + led_set(host_keyboard_leds()); +} /** \brief set host led state * -- cgit v1.2.3