Skip to content

Commit

Permalink
fix voltage threshhold to 2 decimal digits
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Feb 25, 2023
1 parent 17dd9db commit 32342dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/WebApi_powerlimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void WebApiPowerLimiterClass::onStatus(AsyncWebServerRequest* request)
root[F("upper_power_limit")] = config.PowerLimiter_UpperPowerLimit;
root[F("battery_soc_start_threshold")] = config.PowerLimiter_BatterySocStartThreshold;
root[F("battery_soc_stop_threshold")] = config.PowerLimiter_BatterySocStopThreshold;
root[F("voltage_start_threshold")] = config.PowerLimiter_VoltageStartThreshold;
root[F("voltage_stop_threshold")] = config.PowerLimiter_VoltageStopThreshold;
root[F("voltage_start_threshold")] = (int) (config.PowerLimiter_VoltageStartThreshold * 100 +0.5) / 100.0;
root[F("voltage_stop_threshold")] = (int) (config.PowerLimiter_VoltageStopThreshold * 100 +0.5) / 100.0;;
root[F("voltage_load_correction_factor")] = config.PowerLimiter_VoltageLoadCorrectionFactor;

response->setLength();
Expand Down Expand Up @@ -133,7 +133,9 @@ void WebApiPowerLimiterClass::onAdminPost(AsyncWebServerRequest* request)
config.PowerLimiter_BatterySocStartThreshold = root[F("battery_soc_start_threshold")].as<float>();
config.PowerLimiter_BatterySocStopThreshold = root[F("battery_soc_stop_threshold")].as<float>();
config.PowerLimiter_VoltageStartThreshold = root[F("voltage_start_threshold")].as<float>();
config.PowerLimiter_VoltageStartThreshold = (int) (config.PowerLimiter_VoltageStartThreshold * 100) / 100.0;
config.PowerLimiter_VoltageStopThreshold = root[F("voltage_stop_threshold")].as<float>();
config.PowerLimiter_VoltageStopThreshold = (int)(config.PowerLimiter_VoltageStopThreshold * 100) / 100.0;
config.PowerLimiter_VoltageLoadCorrectionFactor = root[F("voltage_load_correction_factor")].as<float>();
Configuration.write();

Expand Down

0 comments on commit 32342dc

Please sign in to comment.