improve battery tracking

This commit is contained in:
2023-02-21 11:49:25 +01:00
parent ba91da7ed3
commit 2f0027b68b
3 changed files with 26 additions and 3 deletions
+6
View File
@@ -33,6 +33,12 @@ double Battery::getBatteryVoltage() {
return (int)(res*100+0.5)/100.0;
}
bool Battery::isBatteryLow(uint8_t percent) {
if (this->getBatteryPercent() <= percent && this->batteryVoltage > this->absurdLowVoltage)
return true;
return false;
}
double Battery::readInputVoltage() {
// Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095
double reading = analogRead(this->pin);