]> www.fi.muni.cz Git - bike-lights.git/commitdiff
pattern.c: alternative brake handling
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 26 Jun 2013 22:15:19 +0000 (00:15 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 26 Jun 2013 22:15:19 +0000 (00:15 +0200)
- when braking, and pwmled0 (read) should be off, we set it to mode 1,
otherwise, we set it to mode 2.

firmware/pattern.c

index c9f4ded4ef230142fc77adecf7669ade8ec1074a..e7a8a09314c8a9a57c8c3a29c726c5893afddd01 100644 (file)
@@ -110,11 +110,14 @@ void pwmleds_update_mode()
        mode1 = (mode >> 2) & 1;
        mode2 = (mode >> 3) & 3;
 
-       if (braking) {
-               if (!mode0)
+       if (braking && !battery_critical) {
+               if (mode0) {
                        mode0 = 2;
-               if (mode2 == 2)
-                       mode2 = 3;
+                       if (mode2 == 2)
+                               mode2 = 3;
+               } else {
+                       mode0 = 1;
+               }
        }
 
        pwmled_set_mode(0, mode0);