From 7ee3a6c8a3314e24c98f2fb8c3a91a443e178758 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Sun, 21 Dec 2014 22:35:48 +0100 Subject: [PATCH] Detect unplugged load --- firmware/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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; } -- 2.43.5