From 32342dcd5d4e5820c2685acbfc662924be9f5bc6 Mon Sep 17 00:00:00 2001 From: helgeerbe Date: Sat, 25 Feb 2023 22:12:44 +0100 Subject: [PATCH] fix voltage threshhold to 2 decimal digits --- src/WebApi_powerlimiter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WebApi_powerlimiter.cpp b/src/WebApi_powerlimiter.cpp index 74892f9ca..380810809 100644 --- a/src/WebApi_powerlimiter.cpp +++ b/src/WebApi_powerlimiter.cpp @@ -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(); @@ -133,7 +133,9 @@ void WebApiPowerLimiterClass::onAdminPost(AsyncWebServerRequest* request) config.PowerLimiter_BatterySocStartThreshold = root[F("battery_soc_start_threshold")].as(); config.PowerLimiter_BatterySocStopThreshold = root[F("battery_soc_stop_threshold")].as(); config.PowerLimiter_VoltageStartThreshold = root[F("voltage_start_threshold")].as(); + config.PowerLimiter_VoltageStartThreshold = (int) (config.PowerLimiter_VoltageStartThreshold * 100) / 100.0; config.PowerLimiter_VoltageStopThreshold = root[F("voltage_stop_threshold")].as(); + config.PowerLimiter_VoltageStopThreshold = (int)(config.PowerLimiter_VoltageStopThreshold * 100) / 100.0; config.PowerLimiter_VoltageLoadCorrectionFactor = root[F("voltage_load_correction_factor")].as(); Configuration.write();