Fix #133 - force deep sleep if battery reaches 10%

This commit is contained in:
geeksville
2020-05-17 04:51:36 -07:00
parent ef1463a6a9
commit efc239533c
3 changed files with 12 additions and 5 deletions

View File

@@ -183,7 +183,7 @@ uint32_t axpDebugRead()
Periodic axpDebugOutput(axpDebugRead);
#endif
#define MIN_BAT_MILLIVOLTS 3690 // millivolts. 10% per https://blog.ampow.com/lipo-voltage-chart/
#define MIN_BAT_MILLIVOLTS 5000 // 3690 // millivolts. 10% per https://blog.ampow.com/lipo-voltage-chart/
/// loop code specific to ESP32 targets
void esp32Loop()
@@ -226,10 +226,9 @@ void esp32Loop()
axp.clearIRQ();
}
float v = axp.getBattVoltage();
DEBUG_MSG("Bat volt %f\n", v);
//if(v >= MIN_BAT_MILLIVOLTS / 2 && v < MIN_BAT_MILLIVOLTS) // If we have a battery at all and it is less than 10% full, force deep sleep
// powerFSM.trigger(EVENT_LOW_BATTERY);
if (powerStatus.haveBattery && !powerStatus.usb &&
axp.getBattVoltage() < MIN_BAT_MILLIVOLTS) // If we have a battery at all and it is less than 10% full, force deep sleep
powerFSM.trigger(EVENT_LOW_BATTERY);
#endif // T_BEAM_V10
}