]> www.fi.muni.cz Git - bike-lights.git/commitdiff
patterns: PATTERN_FOREVER
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 21 Nov 2012 15:30:08 +0000 (16:30 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 21 Nov 2012 15:30:08 +0000 (16:30 +0100)
firmware/lights.h
firmware/pattern.c

index d0eddd79c4837a56368e6906760e11391ca8ffca..eede4d140935182950d2de3e5ff60b7cf0dba224 100644 (file)
@@ -64,6 +64,7 @@ typedef struct {
        unsigned char duration: 5;
 } pattern_t;
 
+#define PATTERN_FOREVER 0x1F
 #define PATTERN_END { 0, 0 }
 extern pattern_t off_pattern[];
 extern pattern_t on_pattern[];
@@ -72,6 +73,7 @@ void pattern_init();
 void patterns_next_tick();
 void led_set_status(unsigned char status);
 void led_set_pattern(unsigned char led, pattern_t *pattern);
+pattern_t *number_pattern(unsigned char num);
 
 /* buttons.c */
 #define MAX_USER_PARAMS 3
index 2e06b67e476fca2c35dad4fe0ef7e39648bff413..a11999d66e152198b7c160a0d1f84cd4274ba2b4 100644 (file)
@@ -6,13 +6,11 @@ static unsigned char led_counters[N_LEDS];
 static pattern_t *led_patterns[N_LEDS];
 
 pattern_t off_pattern[] = {
-       { 0, 0x1F },
-       PATTERN_END
+       { 0, PATTERN_FOREVER },
 };
 
 pattern_t on_pattern[] = {
-       { 1, 0x1F },
-       PATTERN_END
+       { 1, PATTERN_FOREVER },
 };
 
 pattern_t blink_pattern[] = {
@@ -74,7 +72,7 @@ pattern_t pattern_num[] = {
        { 1, 0x1 }, /*  2 */
        { 0, 0x5 },
        { 1, 0x1 }, /*  1 */
-       { 0, 0x1F },
+       { 0, 0x1E },
        PATTERN_END
 };
 
@@ -103,10 +101,9 @@ void pattern_init()
 {
        unsigned char i;
 
-       for (i = 0; i < N_LEDS; i++) {
-               led_counters[i] = 0;
-               led_patterns[i] = off_pattern;
-       }
+       for (i = 0; i < N_LEDS; i++)
+               led_set_pattern(i, off_pattern);
+
        led_set_pattern(N_PWMLEDS+1, boot_pattern);
        test_running = 0;
 }
@@ -145,7 +142,8 @@ void patterns_next_tick()
                        led_set_pattern(i, p);
                }
 
-               led_counters[i]--;
+               if (led_counters[i] < PATTERN_FOREVER)
+                       led_counters[i]--;
        }
 }