]> mj.ucw.cz Git - ursary.git/commitdiff
Lights: Long press = full power
authorMartin Mares <mj@ucw.cz>
Sat, 11 Apr 2020 22:35:48 +0000 (00:35 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 11 Apr 2020 22:35:48 +0000 (00:35 +0200)
ursaryd.c

index 7aa426eb571f6865c02e343fc7b630be92c6f664..e28cebfa4cd2060c8764c053e45c6e53be3d1a62 100644 (file)
--- 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 ***/