- battery calc now more efficent
- new battery values now every 0.5s
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user