summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/led.c15
-rw-r--r--firmware/export/led.h2
2 files changed, 9 insertions, 8 deletions
diff --git a/firmware/drivers/led.c b/firmware/drivers/led.c
index 4b63d07582..4598175b79 100644
--- a/firmware/drivers/led.c
+++ b/firmware/drivers/led.c
@@ -63,14 +63,14 @@ void invert_led(bool on)
63 63
64#else /* no LED, just status update */ 64#else /* no LED, just status update */
65 65
66static long delay; 66static long last_on; /* timestamp of switching off */
67 67
68void led(bool on) 68void led(bool on)
69{ 69{
70 if (current && !on) /* switching off */ 70 if (current && !on) /* switching off */
71 { 71 {
72 delay = current_tick + HZ/2; /* delay the "off" status a bit */ 72 last_on = current_tick; /* remember for off delay */
73 } 73 }
74 current = on; 74 current = on;
75} 75}
76 76
@@ -79,9 +79,10 @@ void invert_led(bool on)
79 (void)on; /* no invert feature */ 79 (void)on; /* no invert feature */
80} 80}
81 81
82bool led_read(void) /* read by status bar update */ 82bool led_read(int delayticks) /* read by status bar update */
83{ 83{
84 return (current || TIME_BEFORE(current_tick, delay)); 84 /* reading "off" is delayed by user-supplied monoflop value */
85 return (current || TIME_BEFORE(current_tick, last_on+delayticks));
85} 86}
86 87
87#endif // #ifdef HAVE_LED 88#endif // #ifdef HAVE_LED
diff --git a/firmware/export/led.h b/firmware/export/led.h
index d7322e465b..052da2633b 100644
--- a/firmware/export/led.h
+++ b/firmware/export/led.h
@@ -25,7 +25,7 @@
25extern void led( bool on ); 25extern void led( bool on );
26extern void invert_led( bool on ); 26extern void invert_led( bool on );
27#ifndef HAVE_LED 27#ifndef HAVE_LED
28extern bool led_read(void); /* read for status bar */ 28extern bool led_read(int delayticks); /* read for status bar */
29#endif 29#endif
30 30
31#endif 31#endif