From 0783a206b221bd103bbf53497dd9f5750c85f3d0 Mon Sep 17 00:00:00 2001 From: Magnus Persson Date: Tue, 4 Jan 2022 11:22:11 +0100 Subject: [PATCH] Added graph + updated formula creation --- html/calibration.htm | 111 +++++++++++++++++++++++++++++++++++++-- html/calibration.min.htm | 53 ++++++++++++++++++- platformio.ini | 2 +- src/calc.cpp | 10 ++-- test/formula.json | 8 +-- 5 files changed, 171 insertions(+), 13 deletions(-) diff --git a/html/calibration.htm b/html/calibration.htm index 84d978b..7a6e1f8 100644 --- a/html/calibration.htm +++ b/html/calibration.htm @@ -8,6 +8,7 @@ + @@ -88,14 +89,15 @@
- Here you can create your gravity formula by entering angles and the corresponding gravity (SG). These values + Here you can create your gravity formula by entering angles/tilt and the corresponding gravity (SG). 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.5 SG then the forumla will be rejected. + formula and if the deviation is more than 1.5 SG 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.
- +
@@ -163,15 +165,73 @@ -
+
+ +
+
+ +

Here you can create your gravity formula by entering angles and the corresponding gravity (SG). 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.5 SG then the forumla will be rejected.

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

Here you can create your gravity formula by entering angles/tilt and the corresponding gravity (SG). 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.5 SG 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 diff --git a/platformio.ini b/platformio.ini index 3acf69d..7e9deec 100644 --- a/platformio.ini +++ b/platformio.ini @@ -34,7 +34,7 @@ build_flags = -D EMBED_HTML # If this is not used the html files needs to be on the file system (can be uploaded) -D USER_SSID=\""\"" # =\""myssid\"" -D USER_SSID_PWD=\""\"" # =\""mypwd\"" - -D CFG_APPVER="\"0.4.0\"" + -D CFG_APPVER="\"0.4.9\"" lib_deps = # Switched to forks for better version control. # Using local copy of this library #https://github.com/mp-se/i2cdevlib # https://github.com/jrowberg/i2cdevlib.git diff --git a/src/calc.cpp b/src/calc.cpp index fbf3408..5f3aed5 100644 --- a/src/calc.cpp +++ b/src/calc.cpp @@ -61,12 +61,16 @@ int createFormula( RawFormulaData& fd, char *formulaBuffer, int order ) { //Returned value is 0 if no error if( ret == 0 ) { - if( noAngles==5 ) + // Print the formula based on 'order' + if( order == 4 ) { + sprintf( formulaBuffer, "%.8f*tilt^4+%.8f*tilt^3+%.8f*tilt^2+%.8f*tilt+%.8f", coeffs[0], coeffs[1], coeffs[2], coeffs[3], coeffs[4] ); + } else if( order == 3 ) { sprintf( formulaBuffer, "%.8f*tilt^3+%.8f*tilt^2+%.8f*tilt+%.8f", coeffs[0], coeffs[1], coeffs[2], coeffs[3] ); - else if( noAngles==4 ) + } else if( order == 2 ) { sprintf( formulaBuffer, "%.8f*tilt^2+%.8f*tilt+%.8f", coeffs[0], coeffs[1], coeffs[2] ); - else // ==3 + } else { // order == 1 sprintf( formulaBuffer, "%.8f*tilt+%.8f", coeffs[0], coeffs[1] ); + } bool valid = true; diff --git a/test/formula.json b/test/formula.json index 88a8ea6..fd53a8b 100644 --- a/test/formula.json +++ b/test/formula.json @@ -1,5 +1,5 @@ { - "gravity-formula": "0.0*tilt^3+0.0*tilt^2+0.0017978*tilt+0.9436", + "gravity-formula": "0.00000166*tilt^3+-0.00024799*tilt^2+0.01344400*tilt+0.79358248", "angle": 45, "a1": 25, "a2": 35, @@ -8,7 +8,7 @@ "a5": 65, "g1": 1.000, "g2": 1.010, - "g3": 1.020, - "g4": 1.030, - "g5": 1.040 + "g3": 1.025, + "g4": 1.040, + "g5": 1.060 } \ No newline at end of file