From: Jan "Yenya" Kasprzak Date: Sun, 21 Dec 2014 21:35:48 +0000 (+0100) Subject: Detect unplugged load X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=7ee3a6c8a3314e24c98f2fb8c3a91a443e178758;p=heater.git Detect unplugged load --- diff --git a/firmware/main.c b/firmware/main.c index 0d45ac9..d238fa8 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -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; }