read initial voltage correctly

This commit is contained in:
Maximilian Mewes 2024-04-30 18:11:18 +02:00
parent 35d26afcb4
commit 05a8c692f2
2 changed files with 3 additions and 2 deletions

View File

@ -27,7 +27,6 @@ class Battery
public:
Battery()
{
this->setVoltage(USERMOD_BATTERY_UNKOWN_MAX_VOLTAGE);
this->setVoltageMultiplier(USERMOD_BATTERY_VOLTAGE_MULTIPLIER);
this->setCalibration(USERMOD_BATTERY_CALIBRATION);
}

View File

@ -150,6 +150,8 @@ class UsermodBattery : public Usermod
// update the choosen battery type with configured values
bat->update(cfg);
bat->setVoltage(readVoltage());
nextReadTime = millis() + readingInterval;
lastReadTime = millis();
@ -389,7 +391,7 @@ class UsermodBattery : public Usermod
addBatteryToJsonObject(battery, false);
// read voltage in case calibration or voltage multiplier changed to see immediate effect
// voltage = readVoltage();
bat->setVoltage(readVoltage());
DEBUG_PRINTLN(F("Battery config saved."));
}