Expose the time of the last change to the LED state (#17222)
This commit is contained in:
		
							parent
							
								
									2af2c5e109
								
							
						
					
					
						commit
						0112938140
					
				
					 2 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			@ -175,6 +184,7 @@ void led_task(void) {
 | 
			
		|||
    uint8_t led_status = host_keyboard_leds();
 | 
			
		||||
    if (last_led_status != led_status) {
 | 
			
		||||
        last_led_status            = led_status;
 | 
			
		||||
        last_led_modification_time = timer_read32();
 | 
			
		||||
 | 
			
		||||
        if (debug_keyboard) {
 | 
			
		||||
            debug("led_task: ");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue