]> www.fi.muni.cz Git - heater.git/commitdiff
Detect unplugged load
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sun, 21 Dec 2014 21:35:48 +0000 (22:35 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sun, 21 Dec 2014 21:35:48 +0000 (22:35 +0100)
firmware/main.c

index 0d45ac93d9a6429bc040486f173f93a2f7d9b0bc..d238fa8703dbe799425071e98e07f26185666c43 100644 (file)
@@ -390,8 +390,14 @@ static void status_led_next_pattern()
 
        if (display_power_level) {
                n_blinks = power_level + 1;
-               blink_on_time = 1;
-               blink_off_time = 2;
+               if (batt_on >> 8 == batt_off >> 8) { // load unplugged
+                       n_blinks = 2 * n_blinks;
+                       blink_on_time = 0;
+                       blink_off_time = 0;
+               } else {
+                       blink_on_time = 2;
+                       blink_off_time = 2;
+               }
        } else {
                unsigned char b_level = battery_level();
                if (b_level) {
@@ -404,11 +410,11 @@ static void status_led_next_pattern()
                }
 
                n_blinks = b_level + 1;
-               blink_on_time = 3;
+               blink_on_time = 4;
                blink_off_time = 0;
        }
 
-       blink_counter = 10;
+       blink_counter = 12;
        display_power_level = !display_power_level;
 }