mirror of
https://github.com/wled/WLED.git
synced 2025-07-23 10:46:33 +00:00
bugfixes
This commit is contained in:
parent
a13f1a9bee
commit
2245ee6fce
@ -27,7 +27,7 @@ class Battery
|
|||||||
public:
|
public:
|
||||||
Battery()
|
Battery()
|
||||||
{
|
{
|
||||||
this->setVoltage(this->getVoltage());
|
this->setVoltage(USERMOD_BATTERY_UNKOWN_MAX_VOLTAGE);
|
||||||
this->setVoltageMultiplier(USERMOD_BATTERY_VOLTAGE_MULTIPLIER);
|
this->setVoltageMultiplier(USERMOD_BATTERY_VOLTAGE_MULTIPLIER);
|
||||||
this->setCalibration(USERMOD_BATTERY_CALIBRATION);
|
this->setCalibration(USERMOD_BATTERY_CALIBRATION);
|
||||||
}
|
}
|
||||||
@ -105,9 +105,10 @@ class Battery
|
|||||||
*/
|
*/
|
||||||
void setVoltage(float voltage)
|
void setVoltage(float voltage)
|
||||||
{
|
{
|
||||||
this->voltage = ( (voltage < this->getMinVoltage() * 0.85f) || (voltage > this->getMaxVoltage() * 1.1f) )
|
// this->voltage = ( (voltage < this->getMinVoltage() * 0.85f) || (voltage > this->getMaxVoltage() * 1.1f) )
|
||||||
? -1.0f
|
// ? -1.0f
|
||||||
: voltage;
|
// : voltage;
|
||||||
|
this->voltage = voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getLevel()
|
float getLevel()
|
||||||
|
@ -28,8 +28,6 @@ class UsermodBattery : public Usermod
|
|||||||
unsigned long lastReadTime = 0;
|
unsigned long lastReadTime = 0;
|
||||||
// between 0 and 1, to control strength of voltage smoothing filter
|
// between 0 and 1, to control strength of voltage smoothing filter
|
||||||
float alpha = USERMOD_BATTERY_AVERAGING_ALPHA;
|
float alpha = USERMOD_BATTERY_AVERAGING_ALPHA;
|
||||||
// offset or calibration value to fine tune the calculated voltage
|
|
||||||
float calibration = USERMOD_BATTERY_CALIBRATION;
|
|
||||||
|
|
||||||
// auto shutdown/shutoff/master off feature
|
// auto shutdown/shutoff/master off feature
|
||||||
bool autoOffEnabled = USERMOD_BATTERY_AUTO_OFF_ENABLED;
|
bool autoOffEnabled = USERMOD_BATTERY_AUTO_OFF_ENABLED;
|
||||||
@ -45,6 +43,7 @@ class UsermodBattery : public Usermod
|
|||||||
unsigned long lowPowerActivationTime = 0; // used temporary during active time
|
unsigned long lowPowerActivationTime = 0; // used temporary during active time
|
||||||
uint8_t lastPreset = 0;
|
uint8_t lastPreset = 0;
|
||||||
|
|
||||||
|
//
|
||||||
bool initDone = false;
|
bool initDone = false;
|
||||||
bool initializing = true;
|
bool initializing = true;
|
||||||
|
|
||||||
@ -311,9 +310,8 @@ class UsermodBattery : public Usermod
|
|||||||
{
|
{
|
||||||
JsonObject battery = root.createNestedObject(FPSTR(_name));
|
JsonObject battery = root.createNestedObject(FPSTR(_name));
|
||||||
|
|
||||||
if (battery.isNull()) {
|
if (battery.isNull())
|
||||||
battery = root.createNestedObject(FPSTR(_name));
|
battery = root.createNestedObject(FPSTR(_name));
|
||||||
}
|
|
||||||
|
|
||||||
addBatteryToJsonObject(battery, true);
|
addBatteryToJsonObject(battery, true);
|
||||||
|
|
||||||
@ -460,8 +458,8 @@ class UsermodBattery : public Usermod
|
|||||||
// calculateTimeLeftEnabled = battery[F("time-left")] | calculateTimeLeftEnabled;
|
// calculateTimeLeftEnabled = battery[F("time-left")] | calculateTimeLeftEnabled;
|
||||||
setMinBatteryVoltage(battery[F("min-voltage")] | bat->getMinVoltage());
|
setMinBatteryVoltage(battery[F("min-voltage")] | bat->getMinVoltage());
|
||||||
setMaxBatteryVoltage(battery[F("max-voltage")] | bat->getMaxVoltage());
|
setMaxBatteryVoltage(battery[F("max-voltage")] | bat->getMaxVoltage());
|
||||||
setCalibration(battery[F("calibration")] | calibration);
|
setCalibration(battery[F("calibration")] | bat->getCalibration());
|
||||||
setVoltageMultiplier(battery[F("voltage-multiplier")] | voltageMultiplier);
|
setVoltageMultiplier(battery[F("voltage-multiplier")] | bat->getVoltageMultiplier());
|
||||||
setReadingInterval(battery[FPSTR(_readInterval)] | readingInterval);
|
setReadingInterval(battery[FPSTR(_readInterval)] | readingInterval);
|
||||||
|
|
||||||
getUsermodConfigFromJsonObject(battery);
|
getUsermodConfigFromJsonObject(battery);
|
||||||
@ -548,14 +546,6 @@ class UsermodBattery : public Usermod
|
|||||||
return cfg.type;
|
return cfg.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set currently active battery type
|
|
||||||
*/
|
|
||||||
batteryType setBatteryType(batteryType type)
|
|
||||||
{
|
|
||||||
cfg.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user