Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.

Tue, 07 Jan 2020 15:47:00 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 07 Jan 2020 15:47:00 +0100
changeset 587
31caffee8c9c
parent 586
ed4f22cfb135
child 588
73e24a609e88

Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.

bmsd/ispindels.c file | annotate | diff | comparison | revisions
bmsd/mysql.c file | annotate | diff | comparison | revisions
www/getispindel.php file | annotate | diff | comparison | revisions
www/js/global.js file | annotate | diff | comparison | revisions
www/js/mon_ispindel.js file | annotate | diff | comparison | revisions
--- a/bmsd/ispindels.c	Mon Jan 06 16:06:28 2020 +0100
+++ b/bmsd/ispindels.c	Tue Jan 07 15:47:00 2020 +0100
@@ -161,7 +161,7 @@
 	snprintf(buf, 64, "%.5f", 1 + (ispindel->gravity / (258.6 - ((ispindel->gravity / 258.2) * 227.1))));
 	line = xstrcat(line, buf);
         line = xstrcat(line, (char *)",");
-        snprintf(buf, 64, "%.5f", ispindel->battery);
+        snprintf(buf, 64, "%.6f", ispindel->battery);
         line = xstrcat(line, buf);
         line = xstrcat(line, (char *)",");
         snprintf(buf, 64, "%.5f", ispindel->angle);
@@ -229,8 +229,8 @@
 	printf("mode        %s\n", ispindel->mode);
 	printf("product     %s / %s\n", ispindel->beercode, ispindel->beername);
         printf("tilt        %.5f\n", ispindel->angle);
-	printf("temperature %.5f\n", ispindel->temperature);
-	printf("battery     %.5f\n", ispindel->battery);
+	printf("temperature %.4f\n", ispindel->temperature);
+	printf("battery     %.6f\n", ispindel->battery);
 	printf("gravity     %.5f\n", ispindel->gravity);
 	printf("interval    %d\n", ispindel->interval);
     }
--- a/bmsd/mysql.c	Mon Jan 06 16:06:28 2020 +0100
+++ b/bmsd/mysql.c	Tue Jan 07 15:47:00 2020 +0100
@@ -729,7 +729,7 @@
 
     snprintf(query, 2559,
         "INSERT INTO mon_ispindels SET uuid='%s', alias='%s', node='%s', online='%d', mode='%s', alarm='%d', " \
-        "angle='%.6f', temperature='%.4f', battery='%.4f', gravity='%.6f', up_interval='%d'",
+        "angle='%.5f', temperature='%.4f', battery='%.6f', gravity='%.5f', up_interval='%d'",
         ispindel->uuid, ispindel->alias, ispindel->node, ispindel->online ? 1:0, ispindel->mode, ispindel->alarm,
         ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval);
 
@@ -747,7 +747,7 @@
 
     snprintf(query, 2559,
         "UPDATE mon_ispindels SET online='%d', mode='%s', alarm='%d', " \
-	"angle='%.3f', temperature='%.3f', battery='%.3f', gravity='%.3f', up_interval='%d' WHERE uuid='%s'",
+	"angle='%.5f', temperature='%.4f', battery='%.6f', gravity='%.5f', up_interval='%d' WHERE uuid='%s'",
         ispindel->online ? 1:0, ispindel->mode, ispindel->alarm,
 	ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval, ispindel->uuid);
 
--- a/www/getispindel.php	Mon Jan 06 16:06:28 2020 +0100
+++ b/www/getispindel.php	Tue Jan 07 15:47:00 2020 +0100
@@ -5,7 +5,7 @@
 if (isset($_GET["uuid"]))
 	    $uuid = $_GET["uuid"];
 else
-	    $uuid = "'ispindel000'";
+	    $uuid = "'c0ffeeee-cafe-dead-bee0-2af236d50dc9'";
 
 
 $mysqli = new mysqli(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
--- a/www/js/global.js	Mon Jan 06 16:06:28 2020 +0100
+++ b/www/js/global.js	Tue Jan 07 15:47:00 2020 +0100
@@ -423,6 +423,7 @@
 Show2dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 2 },
 Show3dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 3 },
 Show4dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 4 },
+Show5dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 5 },
   SGopts = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0.990, max: 1.199, decimalDigits: 3, spinButtons: true },
 Spin1dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true },
 Spin2dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true },
--- a/www/js/mon_ispindel.js	Mon Jan 06 16:06:28 2020 +0100
+++ b/www/js/mon_ispindel.js	Tue Jan 07 15:47:00 2020 +0100
@@ -162,9 +162,9 @@
   }
  });
 
- $('#info_battery').jqxNumberInput(Show3dec);
- $('#info_tilt').jqxNumberInput(Show4dec);
- $('#info_plato').jqxNumberInput(Show4dec);
+ $('#info_battery').jqxNumberInput(Show2dec);
+ $('#info_tilt').jqxNumberInput(Show5dec);
+ $('#info_plato').jqxNumberInput(Show2dec);
  $('#info_sg').jqxNumberInput(Show4dec);
 
  $('#gaugeContainer_temperature').jqxGauge(gaugeoptionst);

mercurial