status-led: put led status in an array
authorCyprien Laplace <cyprien@cypou.net>
Sun, 7 Dec 2014 04:18:52 +0000 (23:18 -0500)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Tue, 8 Nov 2022 16:03:04 +0000 (17:03 +0100)
extdrv/status_led.c

index 8ae531a..9b624f9 100644 (file)
@@ -109,28 +109,23 @@ void status_led(uint32_t val)
        }
 }
 
+static enum led_status steps[] = {
+       red_only,
+       green_only,
+       none,
+       both,
+       none,
+       red_only,
+       red_only,
+       none,
+       green_only,
+       green_only,
+       none
+};
+
 void chenillard(uint32_t ms)
 {
-    status_led(red_only);
-    msleep(ms);
-    status_led(green_only);
-    msleep(ms);
-    status_led(none);
-    msleep(ms);
-    status_led(both);
-    msleep(ms);
-    status_led(none);
-    msleep(ms);
-    status_led(red_only);
-    msleep(ms);
-    status_led(red_only);
-    msleep(ms);
-    status_led(none);
-    msleep(ms);
-    status_led(green_only);
-    msleep(ms);
-    status_led(green_only);
-    msleep(ms);
-    status_led(none);
-    msleep(ms);
+       static int n;
+       status_led(steps[n++ % (sizeof steps / sizeof *steps)]);
+       msleep(ms);
 }