]> www.fi.muni.cz Git - heater.git/blobdiff - firmware/main.c
Detect unplugged load
[heater.git] / 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;
 }