# HG changeset patch # User Michiel Broek # Date 1578408420 -3600 # Node ID 31caffee8c9cda80920664ef5b0b0e48a95b3be1 # Parent ed4f22cfb135afb746a0742ea1b0466ad22cf3fb Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel. diff -r ed4f22cfb135 -r 31caffee8c9c bmsd/ispindels.c --- 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); } diff -r ed4f22cfb135 -r 31caffee8c9c bmsd/mysql.c --- 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); diff -r ed4f22cfb135 -r 31caffee8c9c www/getispindel.php --- 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); diff -r ed4f22cfb135 -r 31caffee8c9c www/js/global.js --- 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 }, diff -r ed4f22cfb135 -r 31caffee8c9c www/js/mon_ispindel.js --- 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);