- battery calc now more efficent

- new battery values now every 0.5s
This commit is contained in:
2023-09-04 15:52:34 +02:00
parent befbd898cc
commit 1d56a2a36d
4 changed files with 20 additions and 8 deletions
+2 -1
View File
@@ -15,6 +15,7 @@ Battery::Battery(uint8_t pin, uint32_t r1, uint32_t r2) {
this->pin = pin;
this->r1 = r1;
this->r2 = r2;
this->batteryVoltageFactor = (double) (this->r1 + this->r2)) / (double) this->r2
this->initBuffer();
this->loopDelay = 100;
}
@@ -71,7 +72,7 @@ double Battery::calculateInputVoltage() {
void Battery::calculateBatteryVoltage() {
if (this->r1 && this->r2) {
this->batteryVoltage = (this->calculateInputVoltage() * (double) (this->r1 + this->r2)) / (double) this->r2;
this->batteryVoltage = (this->calculateInputVoltage() * this->batteryVoltageFactor;
return;
}