Made cal temp adjustable in UI
This commit is contained in:
parent
76702dfc95
commit
bedbda4662
@ -521,6 +521,14 @@
|
||||
<div class="col-sm-5" name="water-angle" id="water-angle"></div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="formula-calibration-temp" class="col-sm-3 col-form-label">Gravity calibration temp</label>
|
||||
<div class="col-sm-3">
|
||||
<input disabled type="number" step=".01" min="0" max="100" class="form-control" name="formula-calibration-temp" id="formula-calibration-temp" placeholder="20" checked data-bs-toggle="tooltip" title="Calibration temperature, used in temperatur correction formula, default 20C/68F">
|
||||
</div>
|
||||
<div class="col-sm-5">(0 - 100) - default 20C/68F</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row mb-3">
|
||||
@ -780,6 +788,7 @@
|
||||
$("#formula-max-deviation").prop("disabled", b);
|
||||
$("#wifi-portal-timeout").prop("disabled", b);
|
||||
$("#wifi-connect-timeout").prop("disabled", b);
|
||||
$("#formula-calibration-temp").prop("disabled", b);
|
||||
$("#int-http1").prop("disabled", b);
|
||||
$("#int-http2").prop("disabled", b);
|
||||
$("#int-http3").prop("disabled", b);
|
||||
@ -794,7 +803,7 @@
|
||||
setButtonDisabled( true );
|
||||
|
||||
var url = "/api/config/advanced";
|
||||
//var url = "/test/adv.json";
|
||||
var url = "/test/adv.json";
|
||||
$('#spinner').show();
|
||||
$.getJSON(url, function (cfg) {
|
||||
console.log( cfg );
|
||||
@ -806,6 +815,7 @@
|
||||
$("#wifi-connect-timeout").val(cfg["wifi-connect-timeout"]);
|
||||
$("#tempsensor-resolution").val(cfg["tempsensor-resolution"]);
|
||||
$("#ignore-low-angles").prop( "checked", cfg["ignore-low-angles"] );
|
||||
$("#formula-calibration-temp").val(cfg["formula-calibration-temp"]);
|
||||
$("#int-http1").val(cfg["int-http1"]);
|
||||
$("#int-http2").val(cfg["int-http2"]);
|
||||
$("#int-http3").val(cfg["int-http3"]);
|
||||
@ -813,7 +823,7 @@
|
||||
$("#int-mqtt").val(cfg["int-mqtt"]);
|
||||
|
||||
if ( cfg["gyro-read-count"] != 50 || cfg["gyro-moving-threashold"] != 500 || cfg["formula-max-deviation"] != 1.6 || cfg["wifi-portal-timeout"] != 120 || cfg["wifi-connect-timeout"] != 20 || cfg["tempsensor-resolution"] != 9 ||
|
||||
cfg["int-http1"] != 0 || cfg["int-http2"] != 0 || cfg["int-http3"] != 0 || cfg["int-influx"] != 0 || cfg["int-mqtt"] != 0 || cfg["ignore-low-angles"] != false ) {
|
||||
cfg["int-http1"] != 0 || cfg["int-http2"] != 0 || cfg["int-http3"] != 0 || cfg["int-influx"] != 0 || cfg["int-mqtt"] != 0 || cfg["ignore-low-angles"] != false || (cfg["formula-calibration-temp"] != 20 && cfg["formula-calibration-temp"] != 68)) {
|
||||
$("#adv-config").attr("checked", false );
|
||||
}
|
||||
})
|
||||
|
File diff suppressed because one or more lines are too long
@ -34,7 +34,7 @@ build_flags =
|
||||
-D USER_SSID=\""\"" # =\""myssid\""
|
||||
-D USER_SSID_PWD=\""\"" # =\""mypwd\""
|
||||
-D CFG_APPVER="\"1.1.0\""
|
||||
-D CFG_GITREV=\""beta-1\""
|
||||
-D CFG_GITREV=\""beta-2\""
|
||||
#!python script/git_rev.py
|
||||
lib_deps = # Switched to forks for better version control.
|
||||
# Using local copy of these libraries
|
||||
|
@ -32,9 +32,8 @@ SOFTWARE.
|
||||
|
||||
double calculateGravity(double angle, double tempC,
|
||||
const char *tempFormula = 0);
|
||||
double gravityTemperatureCorrectionC(
|
||||
double gravity, double tempC,
|
||||
double calTempC = myAdvancedConfig.getDefaultCalibrationTemp());
|
||||
double gravityTemperatureCorrectionC(double gravity, double tempC,
|
||||
double calTempC);
|
||||
int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
||||
int formulaBufferSize, int order);
|
||||
|
||||
|
@ -150,7 +150,7 @@ bool Config::saveFile() {
|
||||
return false;
|
||||
}
|
||||
|
||||
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
|
||||
DynamicJsonDocument doc(3000);
|
||||
createJson(doc);
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||
@ -192,7 +192,7 @@ bool Config::loadFile() {
|
||||
Log.notice(F("CFG : Size of configuration file=%d bytes." CR),
|
||||
configFile.size());
|
||||
|
||||
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
|
||||
DynamicJsonDocument doc(3000);
|
||||
DeserializationError err = deserializeJson(doc, configFile);
|
||||
#if LOG_LEVEL == 6
|
||||
serializeJson(doc, Serial);
|
||||
|
@ -27,8 +27,6 @@ SOFTWARE.
|
||||
#include <helper.hpp>
|
||||
#include <resources.hpp>
|
||||
|
||||
#define CFG_JSON_BUFSIZE 3192
|
||||
|
||||
#define CFG_APPNAME "GravityMon" // Name of firmware
|
||||
#define CFG_FILENAME "/gravitymon.json" // Name of config file
|
||||
#define CFG_HW_FILENAME "/hardware.json" // Name of config file for hw
|
||||
@ -56,12 +54,12 @@ struct RawFormulaData {
|
||||
|
||||
class AdvancedConfig {
|
||||
private:
|
||||
int _wifiPortalTimeout = 120;
|
||||
int _wifiConnectTimeout = 20;
|
||||
float _maxFormulaCreationDeviation = 1.6;
|
||||
float _defaultCalibrationTemp = 20.0;
|
||||
int _wifiPortalTimeout = 120; // seconds
|
||||
int _wifiConnectTimeout = 20; // seconds
|
||||
float _maxFormulaCreationDeviation = 1.6; // SG
|
||||
float _defaultCalibrationTemp = 20.0; // C
|
||||
int _gyroSensorMovingThreashold = 500;
|
||||
int _tempSensorResolution = 9;
|
||||
int _tempSensorResolution = 9; // bits
|
||||
int _gyroReadCount = 50;
|
||||
int _gyroReadDelay = 3150; // us, empirical, to hold sampling to 200 Hz
|
||||
int _pushTimeout = 10; // seconds
|
||||
|
@ -279,7 +279,8 @@ bool loopReadGravity() {
|
||||
LOG_PERF_STOP("loop-temp-read");
|
||||
|
||||
float gravitySG = calculateGravity(angle, tempC);
|
||||
float corrGravitySG = gravityTemperatureCorrectionC(gravitySG, tempC);
|
||||
float corrGravitySG = gravityTemperatureCorrectionC(
|
||||
gravitySG, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
|
||||
|
||||
if (myConfig.isGravityTempAdj()) {
|
||||
gravitySG = corrGravitySG;
|
||||
|
@ -44,7 +44,7 @@ void WebServerHandler::webHandleConfig() {
|
||||
LOG_PERF_START("webserver-api-config");
|
||||
Log.notice(F("WEB : webServer callback for /api/config(get)." CR));
|
||||
|
||||
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
|
||||
DynamicJsonDocument doc(2000);
|
||||
myConfig.createJson(doc);
|
||||
|
||||
doc[PARAM_PASS] = ""; // dont show the wifi password
|
||||
@ -69,8 +69,8 @@ void WebServerHandler::webHandleConfig() {
|
||||
doc[PARAM_TEMP_ADJ] = reduceFloatPrecision(myConfig.getTempSensorAdjC(), 1);
|
||||
|
||||
if (myConfig.isGravityTempAdj()) {
|
||||
gravity =
|
||||
gravityTemperatureCorrectionC(gravity, tempC, myConfig.getTempFormat());
|
||||
gravity = gravityTemperatureCorrectionC(
|
||||
gravity, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
|
||||
}
|
||||
|
||||
if (myConfig.isGravityPlato()) {
|
||||
@ -97,8 +97,9 @@ void WebServerHandler::webHandleConfig() {
|
||||
#endif
|
||||
|
||||
String out;
|
||||
out.reserve(CFG_JSON_BUFSIZE);
|
||||
out.reserve(2000);
|
||||
serializeJson(doc, out);
|
||||
doc.clear();
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
LOG_PERF_STOP("webserver-api-config");
|
||||
}
|
||||
@ -160,6 +161,7 @@ void WebServerHandler::webHandleUpload() {
|
||||
String out;
|
||||
out.reserve(300);
|
||||
serializeJson(doc, out);
|
||||
doc.clear();
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
LOG_PERF_STOP("webserver-api-upload");
|
||||
}
|
||||
@ -325,7 +327,7 @@ void WebServerHandler::webHandleStatus() {
|
||||
LOG_PERF_START("webserver-api-status");
|
||||
Log.notice(F("WEB : webServer callback for /api/status(get)." CR));
|
||||
|
||||
DynamicJsonDocument doc(512);
|
||||
DynamicJsonDocument doc(500);
|
||||
|
||||
double angle = 0;
|
||||
|
||||
@ -337,7 +339,8 @@ void WebServerHandler::webHandleStatus() {
|
||||
doc[PARAM_ID] = myConfig.getID();
|
||||
doc[PARAM_ANGLE] = reduceFloatPrecision(angle);
|
||||
if (myConfig.isGravityTempAdj()) {
|
||||
gravity = gravityTemperatureCorrectionC(gravity, tempC);
|
||||
gravity = gravityTemperatureCorrectionC(
|
||||
gravity, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
|
||||
}
|
||||
if (myConfig.isGravityPlato()) {
|
||||
doc[PARAM_GRAVITY] = reduceFloatPrecision(convertToPlato(gravity), 1);
|
||||
@ -376,8 +379,9 @@ void WebServerHandler::webHandleStatus() {
|
||||
#endif
|
||||
|
||||
String out;
|
||||
out.reserve(300);
|
||||
out.reserve(500);
|
||||
serializeJson(doc, out);
|
||||
doc.clear();
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
LOG_PERF_STOP("webserver-api-status");
|
||||
}
|
||||
@ -671,9 +675,11 @@ void WebServerHandler::webHandleConfigAdvancedWrite() {
|
||||
if (_server->hasArg(PARAM_HW_FORMULA_DEVIATION))
|
||||
myAdvancedConfig.setMaxFormulaCreationDeviation(
|
||||
_server->arg(PARAM_HW_FORMULA_DEVIATION).toFloat());
|
||||
if (_server->hasArg(PARAM_HW_FORMULA_CALIBRATION_TEMP))
|
||||
myAdvancedConfig.SetDefaultCalibrationTemp(
|
||||
_server->arg(PARAM_HW_FORMULA_CALIBRATION_TEMP).toFloat());
|
||||
if (_server->hasArg(PARAM_HW_FORMULA_CALIBRATION_TEMP)) {
|
||||
float t = _server->arg(PARAM_HW_FORMULA_CALIBRATION_TEMP).toFloat();
|
||||
if (myConfig.isTempF()) t = convertFtoC(t);
|
||||
myAdvancedConfig.SetDefaultCalibrationTemp(t);
|
||||
}
|
||||
if (_server->hasArg(PARAM_HW_WIFI_PORTAL_TIMEOUT))
|
||||
myAdvancedConfig.setWifiPortalTimeout(
|
||||
_server->arg(PARAM_HW_WIFI_PORTAL_TIMEOUT).toInt());
|
||||
@ -722,7 +728,7 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
|
||||
LOG_PERF_START("webserver-api-config-advanced");
|
||||
Log.notice(F("WEB : webServer callback for /api/config/advanced(get)." CR));
|
||||
|
||||
DynamicJsonDocument doc(512);
|
||||
DynamicJsonDocument doc(500);
|
||||
|
||||
doc[PARAM_HW_GYRO_READ_COUNT] = myAdvancedConfig.getGyroReadCount();
|
||||
// doc[PARAM_HW_GYRO_READ_DELAY] = myAdvancedConfig.getGyroReadDelay();
|
||||
@ -733,8 +739,9 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
|
||||
doc[PARAM_HW_WIFI_PORTAL_TIMEOUT] = myAdvancedConfig.getWifiPortalTimeout();
|
||||
doc[PARAM_HW_WIFI_CONNECT_TIMEOUT] = myAdvancedConfig.getWifiConnectTimeout();
|
||||
doc[PARAM_HW_PUSH_TIMEOUT] = myAdvancedConfig.getPushTimeout();
|
||||
float t = myAdvancedConfig.getDefaultCalibrationTemp();
|
||||
doc[PARAM_HW_FORMULA_CALIBRATION_TEMP] =
|
||||
myAdvancedConfig.getDefaultCalibrationTemp();
|
||||
myConfig.isTempC() ? t : reduceFloatPrecision(convertCtoF(t), 1);
|
||||
doc[PARAM_HW_PUSH_INTERVAL_HTTP1] = myAdvancedConfig.getPushIntervalHttp1();
|
||||
doc[PARAM_HW_PUSH_INTERVAL_HTTP2] = myAdvancedConfig.getPushIntervalHttp2();
|
||||
doc[PARAM_HW_PUSH_INTERVAL_HTTP3] = myAdvancedConfig.getPushIntervalHttp3();
|
||||
@ -750,8 +757,9 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
|
||||
#endif
|
||||
|
||||
String out;
|
||||
out.reserve(512);
|
||||
out.reserve(500);
|
||||
serializeJson(doc, out);
|
||||
doc.clear();
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
LOG_PERF_STOP("webserver-api-config-advanced");
|
||||
}
|
||||
@ -763,7 +771,7 @@ void WebServerHandler::webHandleFormulaRead() {
|
||||
LOG_PERF_START("webserver-api-formula-read");
|
||||
Log.notice(F("WEB : webServer callback for /api/formula(get)." CR));
|
||||
|
||||
DynamicJsonDocument doc(512);
|
||||
DynamicJsonDocument doc(500);
|
||||
const RawFormulaData& fd = myConfig.getFormulaData();
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
@ -832,8 +840,9 @@ void WebServerHandler::webHandleFormulaRead() {
|
||||
#endif
|
||||
|
||||
String out;
|
||||
out.reserve(256);
|
||||
out.reserve(500);
|
||||
serializeJson(doc, out);
|
||||
doc.clear();
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
LOG_PERF_STOP("webserver-api-formula-read");
|
||||
}
|
||||
@ -908,7 +917,8 @@ void WebServerHandler::webHandleTestPush() {
|
||||
float angle = myGyro.getAngle();
|
||||
float tempC = myTempSensor.getTempC(myConfig.isGyroTemp());
|
||||
float gravitySG = calculateGravity(angle, tempC);
|
||||
float corrGravitySG = gravityTemperatureCorrectionC(gravitySG, tempC);
|
||||
float corrGravitySG = gravityTemperatureCorrectionC(
|
||||
gravitySG, tempC, myAdvancedConfig.getDefaultCalibrationTemp());
|
||||
|
||||
TemplatingEngine engine;
|
||||
engine.initialize(angle, gravitySG, corrGravitySG, tempC, 2.1);
|
||||
@ -943,6 +953,7 @@ void WebServerHandler::webHandleTestPush() {
|
||||
String out;
|
||||
out.reserve(100);
|
||||
serializeJson(doc, out);
|
||||
doc.clear();
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
@ -1005,7 +1016,7 @@ void WebServerHandler::webHandleConfigFormatRead() {
|
||||
LOG_PERF_START("webserver-api-config-format-read");
|
||||
Log.notice(F("WEB : webServer callback for /api/config/formula(get)." CR));
|
||||
|
||||
DynamicJsonDocument doc(2048);
|
||||
DynamicJsonDocument doc(3000);
|
||||
|
||||
doc[PARAM_ID] = myConfig.getID();
|
||||
|
||||
@ -1045,8 +1056,9 @@ void WebServerHandler::webHandleConfigFormatRead() {
|
||||
#endif
|
||||
|
||||
String out;
|
||||
out.reserve(2048);
|
||||
out.reserve(3000);
|
||||
serializeJson(doc, out);
|
||||
doc.clear();
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
LOG_PERF_STOP("webserver-api-config-format-read");
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
Releases
|
||||
########
|
||||
|
||||
v1.1.0
|
||||
======
|
||||
v1.1.0 - beta 2
|
||||
===============
|
||||
|
||||
Documentation
|
||||
+++++++++++++
|
||||
@ -19,6 +19,7 @@ User interface
|
||||
* Under format options its now possible to select brewfather ispindle format to avoid mixing endpoints.
|
||||
* Added brewblox as format under format options.
|
||||
* User can now edit the voltage level that forces the device into config mode (charging)
|
||||
* (beta2) Calibration temperature (for temp adjustment) can now be set under advanced settings.
|
||||
|
||||
Features
|
||||
++++++++
|
||||
@ -36,6 +37,8 @@ Issues adressed
|
||||
++++++++++++++++
|
||||
* BUG: Copy format templates used an old format for iSpindle and Gravmon where the token was not used.
|
||||
* BUG: Gravity correction formula not calculating correctly.
|
||||
* (beta2) BUG: Temp corrected gravity was not used when pushing data to removed
|
||||
* (beta2) BUG: Low memory in format api which resulted in mqtt template to be set to null
|
||||
|
||||
v1.0.0
|
||||
======
|
||||
|
@ -4,13 +4,13 @@
|
||||
"formula-max-deviation": 1.6,
|
||||
"wifi-portal-timeout": 120,
|
||||
"wifi-connect-timeout": 20,
|
||||
"formula-calibration-temp": 20,
|
||||
"tempsensor-resolution": 9,
|
||||
"ignore-low-angles": false,
|
||||
"push-timeout": 10,
|
||||
"formula-calibration-temp": 20,
|
||||
"int-http1": 0,
|
||||
"int-http2": 0,
|
||||
"int-http3": 0,
|
||||
"int-influx": 0,
|
||||
"int-mqtt": 0
|
||||
"int-mqtt": 0,
|
||||
"tempsensor-resolution": 9,
|
||||
"ignore-low-angles": false
|
||||
}
|
Loading…
Reference in New Issue
Block a user