mirror of
https://github.com/wled/WLED.git
synced 2025-04-24 14:57:18 +00:00
Another Bugfx 🧑🔧
This commit is contained in:
parent
3759071449
commit
8ba5dfe447
@ -30,14 +30,7 @@ class Battery
|
||||
|
||||
}
|
||||
|
||||
virtual void update(batteryConfig cfg)
|
||||
{
|
||||
if(cfg.minVoltage) this->setMinVoltage(cfg.minVoltage);
|
||||
if(cfg.maxVoltage) this->setMaxVoltage(cfg.maxVoltage);
|
||||
if(cfg.calibration) this->setCapacity(cfg.calibration);
|
||||
if(cfg.level) this->setLevel(cfg.level);
|
||||
if(cfg.calibration) this->setCalibration(cfg.calibration);
|
||||
}
|
||||
virtual void update(batteryConfig cfg) = 0;
|
||||
|
||||
/**
|
||||
* Corresponding battery curves
|
||||
|
@ -22,6 +22,15 @@ class Lion : public Battery
|
||||
this->setCalibration(USERMOD_BATTERY_LION_CALIBRATION);
|
||||
}
|
||||
|
||||
void update(batteryConfig cfg)
|
||||
{
|
||||
if(cfg.minVoltage) this->setMinVoltage(cfg.minVoltage);
|
||||
if(cfg.maxVoltage) this->setMaxVoltage(cfg.maxVoltage);
|
||||
if(cfg.calibration) this->setCapacity(cfg.calibration);
|
||||
if(cfg.level) this->setLevel(cfg.level);
|
||||
if(cfg.calibration) this->setCalibration(cfg.calibration);
|
||||
}
|
||||
|
||||
float mapVoltage(float v, float min, float max) override
|
||||
{
|
||||
return this->linearMapping(v, min, max); // basic mapping
|
||||
|
@ -22,6 +22,15 @@ class Lipo : public Battery
|
||||
this->setCalibration(USERMOD_BATTERY_LIPO_CALIBRATION);
|
||||
}
|
||||
|
||||
void update(batteryConfig cfg)
|
||||
{
|
||||
if(cfg.minVoltage) this->setMinVoltage(cfg.minVoltage);
|
||||
if(cfg.maxVoltage) this->setMaxVoltage(cfg.maxVoltage);
|
||||
if(cfg.calibration) this->setCapacity(cfg.calibration);
|
||||
if(cfg.level) this->setLevel(cfg.level);
|
||||
if(cfg.calibration) this->setCalibration(cfg.calibration);
|
||||
}
|
||||
|
||||
/**
|
||||
* LiPo batteries have a differnt dischargin curve, see
|
||||
* https://blog.ampow.com/lipo-voltage-chart/
|
||||
|
@ -132,6 +132,7 @@ class UsermodBattery : public Usermod
|
||||
}
|
||||
|
||||
bat->update(bcfg);
|
||||
|
||||
nextReadTime = millis() + readingInterval;
|
||||
lastReadTime = millis();
|
||||
|
||||
@ -316,7 +317,7 @@ class UsermodBattery : public Usermod
|
||||
battery[F("pin")] = batteryPin;
|
||||
#endif
|
||||
|
||||
battery[F("type")] = (String)bcfg.type;
|
||||
battery[F("type")] = (String)bcfg.type; // has to be a String otherwise it won't get converted to a Dropdown
|
||||
battery[F("min-voltage")] = bat->getMinVoltage();
|
||||
battery[F("max-voltage")] = bat->getMaxVoltage();
|
||||
battery[F("capacity")] = bat->getCapacity();
|
||||
@ -404,9 +405,6 @@ class UsermodBattery : public Usermod
|
||||
getJsonValue(battery[F("capacity")], bcfg.capacity);
|
||||
getJsonValue(battery[F("calibration")], bcfg.calibration);
|
||||
setReadingInterval(battery[FPSTR(_readInterval)] | readingInterval);
|
||||
|
||||
// JsonArray type = battery[F("Type")];
|
||||
// batteryType = type["bt"] | btype;
|
||||
|
||||
JsonObject ao = battery[F("auto-off")];
|
||||
setAutoOffEnabled(ao[FPSTR(_enabled)] | autoOffEnabled);
|
||||
@ -444,7 +442,10 @@ class UsermodBattery : public Usermod
|
||||
}
|
||||
#endif
|
||||
|
||||
return !battery[F("min-voltage")].isNull();
|
||||
if(initDone)
|
||||
bat->update(bcfg);
|
||||
|
||||
return !battery[FPSTR(_readInterval)].isNull();
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user