summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/status.c6
-rw-r--r--firmware/drivers/led.c15
-rw-r--r--firmware/export/led.h2
3 files changed, 12 insertions, 11 deletions
diff --git a/apps/status.c b/apps/status.c
index 2af3ea91a4..562cd50964 100644
--- a/apps/status.c
+++ b/apps/status.c
@@ -160,7 +160,7 @@ void status_draw(bool force_redraw)
160 info.repeat = global_settings.repeat_mode; 160 info.repeat = global_settings.repeat_mode;
161 info.playmode = current_playmode(); 161 info.playmode = current_playmode();
162#ifndef HAVE_LED 162#ifndef HAVE_LED
163 info.led = led_read(); 163 info.led = led_read(HZ/2); /* delay should match polling interval */
164#endif 164#endif
165 165
166 /* only redraw if forced to, or info has changed */ 166 /* only redraw if forced to, or info has changed */
@@ -241,8 +241,8 @@ void status_draw(bool force_redraw)
241 statusbar_time(info.hour, info.minute); 241 statusbar_time(info.hour, info.minute);
242#endif 242#endif
243#ifndef HAVE_LED 243#ifndef HAVE_LED
244 if (info.led) 244 if (info.led)
245 statusbar_led(); 245 statusbar_led();
246#endif 246#endif
247 lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT); 247 lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT);
248 lastinfo = info; 248 lastinfo = info;
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