diff options
author | Jouke Witteveen <[email protected]> | 2022-07-02 13:57:05 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-07-02 21:57:05 +1000 |
commit | 0112938140b4a59904f4b0b8c3893588410013cb (patch) | |
tree | a080e4c39d1711a371394c5df7ab71969202d7b1 /quantum/led.c | |
parent | 2af2c5e109cb58401521e32df4b83d7e7f6f1444 (diff) | |
download | qmk_firmware-0112938140b4a59904f4b0b8c3893588410013cb.tar.gz qmk_firmware-0112938140b4a59904f4b0b8c3893588410013cb.zip |
Expose the time of the last change to the LED state (#17222)
Diffstat (limited to 'quantum/led.c')
-rw-r--r-- | quantum/led.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/quantum/led.c b/quantum/led.c index c5ddbc22c5..444d38f751 100644 --- a/quantum/led.c +++ b/quantum/led.c @@ -15,6 +15,7 @@ */ #include "led.h" #include "host.h" +#include "timer.h" #include "debug.h" #include "gpio.h" @@ -54,6 +55,14 @@ static void handle_backlight_caps_lock(led_t led_state) { } #endif +static uint32_t last_led_modification_time = 0; +uint32_t last_led_activity_time(void) { + return last_led_modification_time; +} +uint32_t last_led_activity_elapsed(void) { + return timer_elapsed32(last_led_modification_time); +} + /** \brief Lock LED set callback - keymap/user level * * \deprecated Use led_update_user() instead. @@ -174,7 +183,8 @@ void led_task(void) { // update LED uint8_t led_status = host_keyboard_leds(); if (last_led_status != led_status) { - last_led_status = led_status; + last_led_status = led_status; + last_led_modification_time = timer_read32(); if (debug_keyboard) { debug("led_task: "); |