This commit is contained in:
Magnus Persson 2022-04-29 16:41:44 +02:00
parent 891794af7c
commit 7d9228f9d8
8 changed files with 37 additions and 9 deletions

View File

@ -324,7 +324,7 @@
<div class="accordion-item">
<h2 class="accordion-header" id="headingGravity">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseGravity" aria-expanded="false" aria-controls="collapseGravity">
<b>Gravity</b>
<b>Gravity Settings</b>
</button>
</h2>
<div id="collapseGravity" class="accordion-collapse collapse" aria-labelledby="headingGravity" data-bs-parent="#accordion">
@ -378,7 +378,7 @@
<div class="accordion-item">
<h2 class="accordion-header" id="headingHardware">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseHardware" aria-expanded="false" aria-controls="collapseHardware">
<b>Hardware</b>
<b>Hardware Settings</b>
</button>
</h2>
<div id="collapseHardware" class="accordion-collapse collapse" aria-labelledby="headingHardware" data-bs-parent="#accordion">
@ -453,7 +453,7 @@
<div class="accordion-item">
<h2 class="accordion-header" id="headingAdvanced">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAdvanced" aria-expanded="false" aria-controls="collapseAdvanced">
<b>Advanced (use with caution)</b>
<b>Advanced Settings (use with caution)</b>
</button>
</h2>
<div id="collapseAdvanced" class="accordion-collapse collapse" aria-labelledby="headingAdvanced" data-bs-parent="#accordion">
@ -488,6 +488,16 @@
<hr>
<div class="row mb-3">
<label for="tempsensor-resolution" class="col-sm-3 col-form-label">DS18B20 resolution (bits):</label>
<div class="col-sm-2">
<input disabled type="number" min="9" max="12" class="form-control" name="tempsensor-resolution" id="tempsensor-resolution" checked data-bs-toggle="tooltip" title="Resolution when reading the DS18B20 temperature sensor, higher resolution give better accuracy but takes longer">
</div>
<div class="col-sm-5">(9 - 12) - default 9 bits</div>
</div>
<hr>
<div class="row mb-3">
<label for="wifi-connect-timeout" class="col-sm-3 col-form-label">Wifi connect timeout (s):</label>
<div class="col-sm-2">
@ -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"]);

File diff suppressed because one or more lines are too long

View File

@ -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<int>());
if (!doc[PARAM_HW_PUSH_INTERVAL_MQTT].isNull())
this->setPushIntervalMqtt(doc[PARAM_HW_PUSH_INTERVAL_MQTT].as<int>());
if (!doc[PARAM_HW_TEMPSENSOR_RESOLUTION].isNull())
this->setTempSensorResolution(doc[PARAM_HW_TEMPSENSOR_RESOLUTION].as<int>());
Log.notice(F("CFG : Configuration file " CFG_HW_FILENAME " loaded." CR));
return true;

View File

@ -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; }

View File

@ -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"

View File

@ -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

View File

@ -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);

View File

@ -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,