From: Martin Mares Date: Sat, 11 Apr 2020 22:35:48 +0000 (+0200) Subject: Lights: Long press = full power X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=9462e20b38064dc32852b1f60ad590d65e943f60;p=ursary.git Lights: Long press = full power --- 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 ***/