]> www.fi.muni.cz Git - bike-lights.git/blobdiff - firmware/control.c
battery.c: rework
[bike-lights.git] / firmware / control.c
index eb35aca947ba3be71a0b2b53bb58d96e5e7ad7cd..eeeca84cb1ba5565a384a7a216f26a9ffdfc433b 100644 (file)
@@ -30,15 +30,18 @@ static pattern_t panic_pattern[] = {
 };
 
 pattern_t on1_pattern [] = {
-       { 1, PATTERN_FOREVER }
+       { 1, 0x10 },
+       PATTERN_END
 };
 
 static pattern_t on2_pattern [] = {
-       { 2, PATTERN_FOREVER }
+       { 2, 0x10 },
+       PATTERN_END
 };
 
 static pattern_t on3_pattern [] = {
-       { 3, PATTERN_FOREVER }
+       { 3, 0x10 },
+       PATTERN_END
 };
 
 static pattern_t normal2_pattern[] = {
@@ -123,17 +126,13 @@ pattern_t *pwmled0_pattern_select()
 {
        // TODO: battery critical
 
-#ifndef TESTING_FW
-       return normal3_pattern;
-#endif
-
        if (towbar_mode)
                return NULL;
 
        switch (ambient_zone) {
-       case 0: return dim_mode ? NULL : on1_pattern;
-       case 1: return dim_mode ? NULL : slow2_pattern;
-       case 2: return dim_mode ? slow3_pattern : slow2_pattern;
+       case 0: return dim_mode ? NULL : on3_pattern;
+       case 1: return dim_mode ? NULL : normal3_pattern;
+       case 2: return dim_mode ? slow3_pattern : normal3_pattern;
        case 3:
        default: return dim_mode ? slow3_pattern : normal4_pattern;
        }
@@ -144,8 +143,9 @@ pattern_t *pwmled1_pattern_select()
        // TODO: battery critical
 
 #ifndef TESTING_FW
-       return off_pattern;
+       return NULL;
 #endif
+
        if (towbar_mode) {
                switch (ambient_zone) {
                case 0:
@@ -204,12 +204,19 @@ pattern_t *illumination_led_pattern_select()
                ? number_pattern(2, 1)
                : number_pattern(3, 1);
        case 2: return dim_mode
-               ? number_pattern(3, 0)
-               : number_pattern(4, 0);
+               ? number_pattern(1, 0)
+               : number_pattern(2, 0);
        case 3:
        default: return dim_mode
-               ? number_pattern(5, 0)
-               : number_pattern(6, 0);
+               ? number_pattern(3, 0)
+               : number_pattern(4, 0);
        }
 }
 
+pattern_t *laser_pattern_select()
+{
+       if (!dim_mode && ambient_zone <= 1)
+               return number_pattern(2, 1);
+       else
+               return NULL;
+}