Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the time of the last change to the LED state #17222

Merged
merged 1 commit into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion quantum/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
#include "led.h"
#include "host.h"
#include "timer.h"
#include "debug.h"
#include "gpio.h"

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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: ");
Expand Down
3 changes: 3 additions & 0 deletions quantum/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ void led_set_kb(uint8_t usb_led);
bool led_update_user(led_t led_state);
bool led_update_kb(led_t led_state);

uint32_t last_led_activity_time(void); // Timestamp of the LED activity
uint32_t last_led_activity_elapsed(void); // Number of milliseconds since the last LED activity

#ifdef __cplusplus
}
#endif