From 9462e20b38064dc32852b1f60ad590d65e943f60 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 12 Apr 2020 00:35:48 +0200 Subject: [PATCH] Lights: Long press = full power --- ursaryd.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ursaryd.c b/ursaryd.c index 7aa426e..e28cebf 100644 --- a/ursaryd.c +++ b/ursaryd.c @@ -566,13 +566,34 @@ static void update_lights_from_slider(int value) update_lights(); } +static void lights_button_timeout(struct main_timer *t) +{ + int ch = (uintptr_t) t->data; + DBG("Lights[%d]: Full throttle!", ch); + timer_del(t); + lights_on[ch] = 1; + lights_brightness[ch] = 1; + update_lights(); +} + static void update_lights_from_button(int ch, int on) { + static struct main_timer lights_button_timer[2] = {{ + .handler = lights_button_timeout, + .data = (void *)(uintptr_t) 0, + },{ + .handler = lights_button_timeout, + .data = (void *)(uintptr_t) 1, + }}; + if (on) { lights_on[ch] = !lights_on[ch]; update_lights(); + timer_add_rel(&lights_button_timer[ch], 1000); } + else + timer_del(&lights_button_timer[ch]); } /*** Main update routines ***/ -- 2.39.2