X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=heater.git;a=blobdiff_plain;f=firmware%2Fmain.c;h=65801e81b05fd74192238c0d9892c2d87c9c0b24;hp=95cf70aaf02f9dca561e08d34b55bb856aefc964;hb=3aeea82781e9fc7532861ec6fc5e509efdc799ba;hpb=327136ed7150004f56a0542f8edfda6d95b1b3b8 diff --git a/firmware/main.c b/firmware/main.c index 95cf70a..65801e8 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -79,9 +79,10 @@ static volatile uint16_t batt_on, batt_off; // measured voltage * (1024UL * (mV)) \ / (6UL * ADC_1100MV_VALUE)) >> 8)) static unsigned char batt_levels[] = { - MV_TO_ADC8(3350), - MV_TO_ADC8(3700), - MV_TO_ADC8(3900), + MV_TO_ADC8(3000), // below this, do not enable load, and switch off + MV_TO_ADC8(3150), // below this, switch off after some time + MV_TO_ADC8(3450), // battery low + MV_TO_ADC8(3800), // battery ok, above that almost full }; #define BATT_N_LEVELS (sizeof(batt_levels) / sizeof(batt_levels[0])) @@ -395,7 +396,7 @@ static void status_led_next_pattern() } } else { unsigned char b_level = battery_level(); - if (b_level) { + if (b_level > 1) { battery_exhausted = 0; } else if (battery_exhausted) { if (!--battery_exhausted) @@ -404,8 +405,8 @@ static void status_led_next_pattern() battery_exhausted = LED_BATTEMPTY_COUNT; } - n_blinks = b_level + 1; - blink_on_time = 4; + n_blinks = b_level ? b_level : 1; + blink_on_time = b_level ? 4 : 2; blink_off_time = 0; } @@ -563,6 +564,10 @@ int main() log_byte(batt_on >> 8); #endif } + if (jiffies == 0) { + log_byte(batt_on >> 8); + log_byte(batt_off >> 8); + } log_flush(); } }