diff --git a/html/about.htm b/html/about.htm index 6b5137c..eb3be6d 100644 --- a/html/about.htm +++ b/html/about.htm @@ -5,74 +5,92 @@ Beer Gravity Monitor - - - + + + - + - +
-
-
-
-

Beer Gravity Monitor

- This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project. -
-
-

MIT License

- - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. +
+
+

+ +

+
+
+
+ Beer Gravity Monitor +
+
+ This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project. +
+
+ MIT License +
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +
+
+
+
+
-
-
+ - - -
(C) Copyright 2021-22 Magnus Persson
+
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/calibration.htm b/html/calibration.htm index fc59cf8..3ed1be4 100644 --- a/html/calibration.htm +++ b/html/calibration.htm @@ -5,379 +5,365 @@ 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. -
+
+ + + +
-
- - - -
+
+ +
+
+
-
- -
- +
+ +
+
-
- -
-
-
- -
- +
+ +
+
-
- -
-
-
- -
- +
+ +
+
-
- -
-
-
- -
- +
+ +
+
-
- -
-
-
- -
- +
+
-
- -
-
-
-
- -
-
+
-
- - -
-
+
+ + +
+
- -
- + +
+ +
+
+
+ +
+

+ +

+
+
+ +
-
-
- -
-
-
- + var myChart = 0; + - + } - + function populateChartForm(a, g) { + if( a != 0) + chartDataForm.push( { x: parseFloat(a), y: parseFloat(g) }); -
(C) Copyright 2021-22 Magnus Persson
+ chartDataForm.sort(function (a, b) { + return a.x - b.x; + }); + } + + function populateChartCalc(a, g) { + chartDataCalc.push( { x: parseFloat(a), y: parseFloat(g) }); + } + + function isPlato() { + return $("#gravity-format").text() == "P"; + } + + function populateChart() { + + chartDataCalc.length = 0 + + for( i = 25.0; i<80.0; i+=5.0) { + var formula = $("#formula").text(); + var angle = i.toString(); + formula=formula.replaceAll( "tilt^3", angle+"*"+angle+"*"+angle ); + formula=formula.replaceAll( "tilt^2", angle+"*"+angle ); + formula=formula.replaceAll( "tilt", angle ); + var g = eval( formula ); + + if(isPlato()) + g = convertToPlato(g); + + populateChartCalc( i, g ); + } + + chartDataForm.length = 0 + populateChartForm( $("#a1").val(), $("#g1").val() ); + populateChartForm( $("#a2").val(), $("#g2").val() ); + populateChartForm( $("#a3").val(), $("#g3").val() ); + populateChartForm( $("#a4").val(), $("#g4").val() ); + populateChartForm( $("#a5").val(), $("#g5").val() ); + + if( myChart ) + myChart.destroy(); + + myChart = new Chart( + document.getElementById('gravityChart'), + configChart + ); + } + + function setButtonDisabled( b ) { + $("#calculate-btn").prop("disabled", b); + } + + // Get the configuration values from the API + function getConfig() { + setButtonDisabled( true ); + + var url = "/api/formula"; + var url = "/test/formula.json"; + showError(url); + //showSuccess(url); + $('#spinner').show(); + $.getJSON(url, function (cfg) { + console.log( cfg ); + + $("#id").val(cfg["id"]); + $("#angle").text(cfg["angle"]); + $("#formula").text(cfg["gravity-formula"]); + $("#gravity-format").text(cfg["gravity-format"]); // Sets the variable used by isPlato() + + if(isPlato()) { + $("#gravity-header").text("Gravity (Plato):"); + $("#g1").val( parseFloat(cfg["g1"]).toFixed(1) ); + $("#g2").val( parseFloat(cfg["g2"]).toFixed(1) ); + $("#g3").val( parseFloat(cfg["g3"]).toFixed(1) ); + $("#g4").val( parseFloat(cfg["g4"]).toFixed(1) ); + $("#g5").val( parseFloat(cfg["g5"]).toFixed(1) ); + } else { + $("#gravity-header").text("Gravity (SG):"); + $("#g1").val( parseFloat(cfg["g1"]).toFixed(4) ); + $("#g2").val( parseFloat(cfg["g2"]).toFixed(4) ); + $("#g3").val( parseFloat(cfg["g3"]).toFixed(4) ); + $("#g4").val( parseFloat(cfg["g4"]).toFixed(4) ); + $("#g5").val( parseFloat(cfg["g5"]).toFixed(4) ); + } + + $("#a1").val( parseFloat(cfg["a1"]).toFixed(2) ); + $("#a2").val( parseFloat(cfg["a2"]).toFixed(2) ); + $("#a3").val( parseFloat(cfg["a3"]).toFixed(2) ); + $("#a4").val( parseFloat(cfg["a4"]).toFixed(2) ); + $("#a5").val( parseFloat(cfg["a5"]).toFixed(2) ); + + if( cfg["error"]!="" ) { + showError(cfg["error"]); + } + + populateChart(); + }) + .fail(function () { + showError('Unable to get data from the device.'); + }) + .always(function() { + $('#spinner').hide(); + setButtonDisabled( false ); + }); + } + + + + +
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/config.htm b/html/config.htm index c4ef28e..bf8e6e0 100644 --- a/html/config.htm +++ b/html/config.htm @@ -5,136 +5,138 @@ Beer Gravity Monitor - + + + - + - + - + - +
-
+ -
+ - + - + + function showWarningSleep() { + $('#warning-sleep').removeClass('d-none').addClass('show').removeClass('hide'); + } + function hideWarningSleep() { + $('#warning-sleep').addClass('d-none').removeClass('show').addClass('hide'); + } + function showWarningGyro() { + $('#warning-gyro').removeClass('d-none').addClass('show').removeClass('hide'); + } + function hideWarningGyro() { + $('#warning-gyro').addClass('d-none').removeClass('show').addClass('hide'); + } +
- +
+

+ +

+
+
-
-
-

- -

-
-
-
-
+ +
-
+
-
- Temperature Format: -
-
- - + +
+
+ Temperature Format: +
+
+ + +
+
+ + +
-
- - -
-
-
-
+ +
+ +
-
+ +
@@ -143,7 +145,7 @@
-
+
@@ -156,16 +158,14 @@
-
-
-

- -

-
-
-
+
+

+ +

+
+
@@ -174,68 +174,58 @@ -
+
- +
-
+ +
- +
-
+
-
- -
+
-
+
-
- -
- -
- -
-
- -
+
-
+
- - + +
@@ -243,39 +233,41 @@
-
-
-

- -

-
-
-
+
+

+ +

+
+
+
-
+
-
+
-
+ +
-
+ +
-
+ +
@@ -284,42 +276,45 @@
-
+
-
+ +
-
+ +
-
+ +
-
+
-
+
- - + +
@@ -327,52 +322,51 @@
-
-
-

- -

-
-
-
+
+

+ +

+
+
+
-
- Gravity Format: -
-
- - + +
+
+ Gravity Format: +
+
+ + +
+
+ + +
-
- - -
-
-
-
- + +
+ +
+
-
+ +
- +
-
+ +
@@ -382,45 +376,46 @@
-
-
-

- -

-
-
-
+
+

+ +

+
+
+ -
+ +
-
+ +
-
+ +
- +
-
+ +
- @@ -433,21 +428,24 @@
-
+ +
-
+
-
+ +
-
+ +
- +
@@ -455,236 +453,238 @@
-
-
- -