full update for BatteryHealthMonitor

This commit is contained in:
richonguzman 2024-05-24 14:24:40 -04:00
parent c6687529da
commit 3589f54d02
9 changed files with 61 additions and 21 deletions

View file

@ -1,9 +1,11 @@
#include "battery_utils.h"
#include "configuration.h"
#include "boards_pinout.h"
#include "utils.h"
extern Configuration Config;
extern uint32_t lastBatteryCheck;
extern bool shouldSleepLowVoltage;
float adcReadingTransformation = (3.3/4095);
float voltageDividerCorrection = 0.288;
@ -88,4 +90,18 @@ namespace BATTERY_Utils {
}
}
void startupBatteryHealth() {
#ifdef BATTERY_PIN
if (Config.battery.monitorInternalVoltage && checkInternalVoltage() < Config.battery.internalSleepVoltage) {
shouldSleepLowVoltage = true;
}
#endif
if (Config.battery.monitorExternalVoltage && checkExternalVoltage() < Config.battery.externalSleepVoltage) {
shouldSleepLowVoltage = true;
}
if (shouldSleepLowVoltage) {
Utils::checkSleepByLowBatteryVoltage(0);
}
}
}