diff --git a/html/config.htm b/html/config.htm index 14ed0cc..f2aba37 100644 --- a/html/config.htm +++ b/html/config.htm @@ -324,7 +324,7 @@

@@ -378,7 +378,7 @@

@@ -453,7 +453,7 @@

@@ -488,6 +488,16 @@
+
+ +
+ +
+
(9 - 12) - default 9 bits
+
+ +
+
@@ -749,6 +759,7 @@ $("#int-http3").prop("disabled", b); $("#int-influx").prop("disabled", b); $("#int-mqtt").prop("disabled", b); + $("#tempsensor-resolution").prop("disabled", b); } // Get the advanced values from the API @@ -766,6 +777,7 @@ $("#formula-max-deviation").val(cfg["formula-max-deviation"]); $("#wifi-portal-timeout").val(cfg["wifi-portal-timeout"]); $("#wifi-connect-timeout").val(cfg["wifi-connect-timeout"]); + $("#tempsensor-resolution").val(cfg["tempsensor-resolution"]); $("#int-http1").val(cfg["int-http1"]); $("#int-http2").val(cfg["int-http2"]); $("#int-http3").val(cfg["int-http3"]); diff --git a/html/config.min.htm b/html/config.min.htm index 7af949c..538c99b 100644 --- a/html/config.min.htm +++ b/html/config.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

Temperature Format:


Gravity Format:

(10-100) - default 50
(50-1000) - default 500
(1 - 10) - default 1.6 SG

(1 - 60) - default 20 s
(10 - 240) - default 120 s

(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Temperature Format:


Gravity Format:

(10-100) - default 50
(50-1000) - default 500
(1 - 10) - default 1.6 SG

(9 - 12) - default 9 bits

(1 - 60) - default 20 s
(10 - 240) - default 120 s

(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/src/config.cpp b/src/config.cpp index eed1152..70d2dc9 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -390,6 +390,7 @@ bool AdvancedConfig::saveFile() { doc[PARAM_HW_PUSH_INTERVAL_HTTP3] = this->getPushIntervalHttp3(); doc[PARAM_HW_PUSH_INTERVAL_INFLUX] = this->getPushIntervalInflux(); doc[PARAM_HW_PUSH_INTERVAL_MQTT] = this->getPushIntervalMqtt(); + doc[PARAM_HW_TEMPSENSOR_RESOLUTION] = this->getTempSensorResolution(); #if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING) serializeJson(doc, Serial); @@ -476,6 +477,8 @@ bool AdvancedConfig::loadFile() { this->setPushIntervalInflux(doc[PARAM_HW_PUSH_INTERVAL_INFLUX].as()); if (!doc[PARAM_HW_PUSH_INTERVAL_MQTT].isNull()) this->setPushIntervalMqtt(doc[PARAM_HW_PUSH_INTERVAL_MQTT].as()); + if (!doc[PARAM_HW_TEMPSENSOR_RESOLUTION].isNull()) + this->setTempSensorResolution(doc[PARAM_HW_TEMPSENSOR_RESOLUTION].as()); Log.notice(F("CFG : Configuration file " CFG_HW_FILENAME " loaded." CR)); return true; diff --git a/src/config.hpp b/src/config.hpp index 521e2b2..68f1631 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -61,6 +61,7 @@ class AdvancedConfig { float _maxFormulaCreationDeviation = 1.6; float _defaultCalibrationTemp = 20.0; int _gyroSensorMovingThreashold = 500; + int _tempSensorResolution = 9; int _gyroReadCount = 50; int _gyroReadDelay = 3150; // us, empirical, to hold sampling to 200 Hz int _pushTimeout = 10; // seconds @@ -84,6 +85,12 @@ class AdvancedConfig { _maxFormulaCreationDeviation = f; } + int getTempSensorResolution() { return _tempSensorResolution; } + void setTempSensorResolution(int t) { + if (t>=9 && t<=12) + _tempSensorResolution = t; + } + float getDefaultCalibrationTemp() { return _defaultCalibrationTemp; } void SetDefaultCalibrationTemp(float t) { _defaultCalibrationTemp = t; } diff --git a/src/resources.hpp b/src/resources.hpp index 65fdc52..fed0c41 100644 --- a/src/resources.hpp +++ b/src/resources.hpp @@ -83,6 +83,7 @@ SOFTWARE. #define PARAM_HW_FORMULA_CALIBRATION_TEMP "formula-calibration-temp" #define PARAM_HW_WIFI_PORTAL_TIMEOUT "wifi-portal-timeout" #define PARAM_HW_WIFI_CONNECT_TIMEOUT "wifi-connect-timeout" +#define PARAM_HW_TEMPSENSOR_RESOLUTION "tempsensor-resolution" #define PARAM_HW_PUSH_TIMEOUT "push-timeout" #define PARAM_HW_PUSH_INTERVAL_HTTP1 "int-http1" #define PARAM_HW_PUSH_INTERVAL_HTTP2 "int-http2" diff --git a/src/tempsensor.cpp b/src/tempsensor.cpp index 4cabbd7..f2c79b6 100644 --- a/src/tempsensor.cpp +++ b/src/tempsensor.cpp @@ -32,7 +32,6 @@ SOFTWARE. OneWire myOneWire(PIN_DS); DallasTemperature mySensors(&myOneWire); -#define TEMPERATURE_PRECISION 9 TempSensor myTempSensor; @@ -52,10 +51,10 @@ void TempSensor::setup() { if (mySensors.getDS18Count()) { #if !defined(TSEN_DISABLE_LOGGING) - Log.notice(F("TSEN: Found %d temperature sensor(s)." CR), - mySensors.getDS18Count()); + Log.notice(F("TSEN: Found %d temperature sensor(s). Using %d resolution" CR), + mySensors.getDS18Count(), myAdvancedConfig.getTempSensorResolution()); #endif - mySensors.setResolution(TEMPERATURE_PRECISION); + mySensors.setResolution(myAdvancedConfig.getTempSensorResolution()); } // Set the temp sensor adjustment values diff --git a/src/webserver.cpp b/src/webserver.cpp index 0affbf5..8838634 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -324,7 +324,7 @@ void WebServerHandler::webHandleStatus() { LOG_PERF_START("webserver-api-status"); Log.notice(F("WEB : webServer callback for /api/status(get)." CR)); - DynamicJsonDocument doc(300); + DynamicJsonDocument doc(512); double angle = 0; @@ -683,6 +683,9 @@ void WebServerHandler::webHandleConfigAdvancedWrite() { if (_server->hasArg(PARAM_HW_PUSH_INTERVAL_MQTT)) myAdvancedConfig.setPushIntervalMqtt( _server->arg(PARAM_HW_PUSH_INTERVAL_MQTT).toInt()); + if (_server->hasArg(PARAM_HW_TEMPSENSOR_RESOLUTION)) + myAdvancedConfig.setTempSensorResolution( + _server->arg(PARAM_HW_TEMPSENSOR_RESOLUTION).toInt()); myAdvancedConfig.saveFile(); _server->sendHeader("Location", "/config.htm#collapseAdvanced", true); @@ -715,6 +718,8 @@ void WebServerHandler::webHandleConfigAdvancedRead() { doc[PARAM_HW_PUSH_INTERVAL_HTTP3] = myAdvancedConfig.getPushIntervalHttp3(); doc[PARAM_HW_PUSH_INTERVAL_INFLUX] = myAdvancedConfig.getPushIntervalInflux(); doc[PARAM_HW_PUSH_INTERVAL_MQTT] = myAdvancedConfig.getPushIntervalMqtt(); + doc[PARAM_HW_TEMPSENSOR_RESOLUTION] = + myAdvancedConfig.getTempSensorResolution(); #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) serializeJson(doc, Serial); diff --git a/test/adv.json b/test/adv.json index 160ecf2..4ee53db 100644 --- a/test/adv.json +++ b/test/adv.json @@ -5,6 +5,7 @@ "wifi-portal-timeout": 121, "wifi-connect-timeout": 21, "formula-calibration-temp": 21, + "tempsensor-resolution": 12, "push-timeout": 10, "int-http1": 1, "int-http2": 2,