This commit is contained in:
stevenhowes
2018-09-13 20:45:02 +01:00
parent 913692694f
commit 437a2cc9a5
9 changed files with 43 additions and 70 deletions
+8
View File
@@ -1,7 +1,9 @@
void battery_init()
{
// Run once to get start info
task_battery_run();
// Log if battery is exceptional in any way
if(battery_voltage_value < 12)
{
Serial.println("ERR: Battery low");
@@ -11,12 +13,18 @@ void battery_init()
Serial.println("ERR: Battery high");
}
else
{
Serial.println("INF: Battery ok");
}
}
void task_battery_run()
{
// Min/Max we care about are 7 and 16. Anything that low or high is bad so outside of that
// doesn't need any special consideration
battery_voltage_value = map(analogRead(pin_batt), battery_cal_7v, battery_cal_16v, 7, 16);
// Nudge it along so we have an index starting at 0 for tables etc
battery_voltage_index = constrain(battery_voltage_value,7,16) - 7;
}