diff --git a/html/calibration.htm b/html/calibration.htm index 07c8bbd..5726699 100644 --- a/html/calibration.htm +++ b/html/calibration.htm @@ -91,38 +91,56 @@
- - + +
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
@@ -220,12 +238,18 @@ g3.onchange = setGravityDecimal g4.onchange = setGravityDecimal g5.onchange = setGravityDecimal + g6.onchange = setGravityDecimal + g7.onchange = setGravityDecimal + g8.onchange = setGravityDecimal a1.onchange = setAngleDecimal a2.onchange = setAngleDecimal a3.onchange = setAngleDecimal a4.onchange = setAngleDecimal a5.onchange = setAngleDecimal + a6.onchange = setAngleDecimal + a7.onchange = setAngleDecimal + a8.onchange = setAngleDecimal window.onload = getConfig; setButtonDisabled( true ); @@ -293,6 +317,9 @@ populateChartForm( $("#a3").val(), $("#g3").val() ); populateChartForm( $("#a4").val(), $("#g4").val() ); populateChartForm( $("#a5").val(), $("#g5").val() ); + populateChartForm( $("#a6").val(), $("#g6").val() ); + populateChartForm( $("#a7").val(), $("#g7").val() ); + populateChartForm( $("#a8").val(), $("#g8").val() ); if( myChart ) myChart.destroy(); @@ -336,6 +363,9 @@ $("#g3").val( parseFloat(cfg["g3"]).toFixed(4) ); $("#g4").val( parseFloat(cfg["g4"]).toFixed(4) ); $("#g5").val( parseFloat(cfg["g5"]).toFixed(4) ); + $("#g6").val( parseFloat(cfg["g6"]).toFixed(4) ); + $("#g7").val( parseFloat(cfg["g7"]).toFixed(4) ); + $("#g8").val( parseFloat(cfg["g8"]).toFixed(4) ); } $("#a1").val( parseFloat(cfg["a1"]).toFixed(2) ); @@ -343,6 +373,9 @@ $("#a3").val( parseFloat(cfg["a3"]).toFixed(2) ); $("#a4").val( parseFloat(cfg["a4"]).toFixed(2) ); $("#a5").val( parseFloat(cfg["a5"]).toFixed(2) ); + $("#a6").val( parseFloat(cfg["a6"]).toFixed(2) ); + $("#a7").val( parseFloat(cfg["a7"]).toFixed(2) ); + $("#a8").val( parseFloat(cfg["a8"]).toFixed(2) ); if( cfg["error"]!="" ) { showError(cfg["error"]); diff --git a/html/calibration.min.htm b/html/calibration.min.htm index 4e9537e..09cc5d7 100644 --- a/html/calibration.min.htm +++ b/html/calibration.min.htm @@ -1,4 +1,4 @@ -Beer Gravity Monitor

Here you can create your gravity formula by entering angles/tilt and the corresponding gravity. These values will be saved for future use. Angles with 0 (zero) will be skipped. The values below will be used to check the formula and if the deviation is more than 1.5SG / 0.38P on any of the provided points then the forumla will be rejected. On the bottom of the page you can see a graph over the entered values + values calcualated by the formula.

Here you can create your gravity formula by entering angles/tilt and the corresponding gravity. These values will be saved for future use. Angles with 0 (zero) will be skipped. The values below will be used to check the formula and if the deviation is more than 1.5SG / 0.38P on any of the provided points then the forumla will be rejected. On the bottom of the page you can see a graph over the entered values + values calcualated by the formula.

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file + var myChart = 0;
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/config.htm b/html/config.htm index b9cc120..b95a591 100644 --- a/html/config.htm +++ b/html/config.htm @@ -106,16 +106,16 @@
- +
-
- Temperature Format: -
+
+ Temperature Format: +
@@ -129,7 +129,7 @@
- +
@@ -137,7 +137,7 @@
-
+
@@ -146,10 +146,10 @@
- - - -
+ + + +
diff --git a/html/config.min.htm b/html/config.min.htm index 488f064..ef6ca3d 100644 --- a/html/config.min.htm +++ b/html/config.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

Temperature Format:


Gravity Format:

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

Temperature Format:


Gravity Format:

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/src/calc.cpp b/src/calc.cpp index 4624cf8..8642d46 100644 --- a/src/calc.cpp +++ b/src/calc.cpp @@ -33,14 +33,16 @@ SOFTWARE. int createFormula(RawFormulaData &fd, char *formulaBuffer, int formulaBufferSize, int order) { int noAngles = 0; + RawFormulaData fd2; - // Check how many valid values we have got - if (fd.a[0] > 0 && fd.a[1] > 0 && fd.a[2] > 0 && fd.a[3] > 0 && fd.a[4] > 0) - noAngles = 5; - else if (fd.a[0] > 0 && fd.a[1] > 0 && fd.a[2] > 0 && fd.a[3] > 0) - noAngles = 4; - else if (fd.a[0] > 0 && fd.a[1] > 0 && fd.a[2] > 0) - noAngles = 3; + // Check how many valid values we have got and make sure we have a full series. + for (int i = 0; i < FORMULA_DATA_SIZE; i++) { + if (fd.a[i]) { + fd2.a[noAngles] = fd.a[i]; + fd2.g[noAngles] = fd.g[i]; + noAngles++; + } + } #if LOG_LEVEL == 6 && !defined(CALC_DISABLE_LOGGING) Log.verbose( @@ -54,13 +56,13 @@ int createFormula(RawFormulaData &fd, char *formulaBuffer, return ERR_FORMULA_NOTENOUGHVALUES; } else { double coeffs[order + 1]; - int ret = fitCurve(order, noAngles, fd.a, fd.g, + int ret = fitCurve(order, noAngles, fd2.a, fd2.g, sizeof(coeffs) / sizeof(double), coeffs); // Returned value is 0 if no error if (ret == 0) { #if LOG_LEVEL == 6 && !defined(CALC_DISABLE_LOGGING) - Log.verbose(F("CALC: Finshied processing data points." CR)); + Log.verbose(F("CALC: Finshied processing data points, order = %d." CR), order); #endif // Print the formula based on 'order' diff --git a/src/config.hpp b/src/config.hpp index 653dc3b..7113cfd 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -47,9 +47,11 @@ struct RawGyroData { }; // Used for holding formulaData (used for calculating formula on device) +#define FORMULA_DATA_SIZE 8 + struct RawFormulaData { - double a[5]; - double g[5]; + double a[FORMULA_DATA_SIZE]; + double g[FORMULA_DATA_SIZE]; }; class HardwareConfig { diff --git a/src/webserver.cpp b/src/webserver.cpp index 7d528c8..704a781 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -696,7 +696,7 @@ void WebServerHandler::webHandleFormulaRead() { LOG_PERF_START("webserver-api-formula-read"); Log.notice(F("WEB : webServer callback for /api/formula(get)." CR)); - DynamicJsonDocument doc(250); + DynamicJsonDocument doc(512); const RawFormulaData& fd = myConfig.getFormulaData(); #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) @@ -729,6 +729,9 @@ void WebServerHandler::webHandleFormulaRead() { doc["a3"] = reduceFloatPrecision(fd.a[2], 2); doc["a4"] = reduceFloatPrecision(fd.a[3], 2); doc["a5"] = reduceFloatPrecision(fd.a[4], 2); + doc["a6"] = reduceFloatPrecision(fd.a[5], 2); + doc["a7"] = reduceFloatPrecision(fd.a[6], 2); + doc["a8"] = reduceFloatPrecision(fd.a[7], 2); if (myConfig.isGravityPlato()) { doc["g1"] = reduceFloatPrecision(convertToPlato(fd.g[0]), 1); @@ -736,12 +739,18 @@ void WebServerHandler::webHandleFormulaRead() { doc["g3"] = reduceFloatPrecision(convertToPlato(fd.g[2]), 1); doc["g4"] = reduceFloatPrecision(convertToPlato(fd.g[3]), 1); doc["g5"] = reduceFloatPrecision(convertToPlato(fd.g[4]), 1); + doc["g6"] = reduceFloatPrecision(convertToPlato(fd.g[5]), 1); + doc["g7"] = reduceFloatPrecision(convertToPlato(fd.g[6]), 1); + doc["g8"] = reduceFloatPrecision(convertToPlato(fd.g[7]), 1); } else { doc["g1"] = reduceFloatPrecision(fd.g[0], 4); doc["g2"] = reduceFloatPrecision(fd.g[1], 4); doc["g3"] = reduceFloatPrecision(fd.g[2], 4); doc["g4"] = reduceFloatPrecision(fd.g[3], 4); doc["g5"] = reduceFloatPrecision(fd.g[4], 4); + doc["g6"] = reduceFloatPrecision(fd.g[5], 4); + doc["g7"] = reduceFloatPrecision(fd.g[6], 4); + doc["g8"] = reduceFloatPrecision(fd.g[7], 4); } #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) @@ -995,6 +1004,9 @@ void WebServerHandler::webHandleFormulaWrite() { fd.a[2] = _server->arg("a3").toDouble(); fd.a[3] = _server->arg("a4").toDouble(); fd.a[4] = _server->arg("a5").toDouble(); + fd.a[5] = _server->arg("a6").toDouble(); + fd.a[6] = _server->arg("a7").toDouble(); + fd.a[7] = _server->arg("a8").toDouble(); if (myConfig.isGravityPlato()) { fd.g[0] = convertToSG(_server->arg("g1").toDouble()); @@ -1002,12 +1014,18 @@ void WebServerHandler::webHandleFormulaWrite() { fd.g[2] = convertToSG(_server->arg("g3").toDouble()); fd.g[3] = convertToSG(_server->arg("g4").toDouble()); fd.g[4] = convertToSG(_server->arg("g5").toDouble()); + fd.g[5] = convertToSG(_server->arg("g6").toDouble()); + fd.g[6] = convertToSG(_server->arg("g7").toDouble()); + fd.g[7] = convertToSG(_server->arg("g8").toDouble()); } else { fd.g[0] = _server->arg("g1").toDouble(); fd.g[1] = _server->arg("g2").toDouble(); fd.g[2] = _server->arg("g3").toDouble(); fd.g[3] = _server->arg("g4").toDouble(); fd.g[4] = _server->arg("g5").toDouble(); + fd.g[5] = _server->arg("g6").toDouble(); + fd.g[6] = _server->arg("g7").toDouble(); + fd.g[7] = _server->arg("g8").toDouble(); } myConfig.setFormulaData(fd); diff --git a/test/formula.json b/test/formula.json index a5906d5..9fea7de 100644 --- a/test/formula.json +++ b/test/formula.json @@ -6,10 +6,16 @@ "a2": 45, "a4": 55, "a5": 30, + "a6": 30, + "a7": 30, + "a8": 30, "g1": 1.000, "g3": 1.010, "g2": 1.025, "g4": 1.040, "g5": 1.005, + "g6": 1.005, + "g7": 1.005, + "g8": 1.005, "error": "" } \ No newline at end of file