mirror of
https://github.com/stevenhowes/MX5-Arduino.git
synced 2026-05-27 00:03:37 +01:00
Cleanup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user