]> www.fi.muni.cz Git - bike-lights.git/commitdiff
control.c: handle "battery critical" state
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 28 Feb 2013 00:00:57 +0000 (01:00 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 28 Feb 2013 00:07:56 +0000 (01:07 +0100)
firmware/control.c
firmware/lights.h

index 1a768e6ca9d2d84f5b3932a7424c9a1bd6201178..7a8d4473c9cf52da0640e3e3870f88cd2de69711 100644 (file)
@@ -124,7 +124,8 @@ void set_panic_mode()
 
 pattern_t *pwmled0_pattern_select()
 {
-       // TODO: battery critical
+       if (battery_critical)
+               return on1_pattern;
 
        if (towbar_mode)
                return NULL;
@@ -140,10 +141,11 @@ pattern_t *pwmled0_pattern_select()
 
 pattern_t *pwmled1_pattern_select()
 {
-       // TODO: battery critical
-
 #ifndef TESTING_FW
        return NULL;
+#else
+       if (battery_critical)
+               return on1_pattern;
 #endif
 
        if (towbar_mode) {
@@ -168,11 +170,11 @@ pattern_t *pwmled1_pattern_select()
 
 pattern_t *pwmled2_pattern_select()
 {
-       // TODO: battery critical
-
 #ifndef TESTING_FW
-       return on3_pattern;
+       if (battery_critical)
+               return on1_pattern;
 #endif
+
        switch (ambient_zone) {
        case 0: return dim_mode ? on2_pattern : on3_pattern;
        case 1: return dim_mode ? slow1_pattern : normal2_pattern;
@@ -194,7 +196,8 @@ pattern_t *status_led_pattern_select()
 
 pattern_t *illumination_led_pattern_select()
 {
-       // todo: battery critical
+       if (battery_critical)
+               return NULL;
 
        switch (ambient_zone) {
        case 0: return dim_mode
index 5032e1124b8633f2250a608632062192f63c536c..7bdc5b65619d09502f9a7eab7ac92ec2d0858f9a 100644 (file)
@@ -88,6 +88,7 @@ pattern_t *buttons_setup_status0_pattern_select();
 pattern_t *buttons_setup_status1_pattern_select();
 
 /* battery.c */
+extern volatile unsigned char battery_critical;
 void battery_adc();
 void init_battery();
 unsigned char battery_gauge();