]> www.fi.muni.cz Git - bike-lights.git/commitdiff
pattern.c: off_pattern should not last forever
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sun, 16 Dec 2012 16:22:26 +0000 (17:22 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sun, 16 Dec 2012 16:22:26 +0000 (17:22 +0100)
firmware/pattern.c

index 59692bf32a97e07f6f468d878e33cf9c1c7e980d..d5720b0a304bee8cd7f5c9f9bc654a6a9b9834b9 100644 (file)
@@ -76,6 +76,11 @@ static pattern_t pattern_invnum[] = {
        PATTERN_END
 };
 
+pattern_t off_pattern[] = {
+       { 0, 0x1E },
+       PATTERN_END
+};
+
 static void led_set_mode(unsigned char n, unsigned char mode)
 {
        if (n < N_PWMLEDS) {
@@ -87,12 +92,10 @@ static void led_set_mode(unsigned char n, unsigned char mode)
 
 void led_set_pattern(unsigned char n, pattern_t *pattern)
 {
-       led_patterns[n] = pattern;
+       if (!pattern)
+               pattern = off_pattern;
 
-       if (!pattern) {
-               led_set_mode(n, 0);
-               return;
-       }
+       led_patterns[n] = pattern;
 
        led_counters[n] = pattern->duration;
        led_set_mode(n, pattern->mode);