Adding moving info on html

This commit is contained in:
Magnus Persson 2022-02-14 21:48:34 +01:00
parent b43874d151
commit 10ce1fc245
3 changed files with 22 additions and 9 deletions

View File

@ -122,12 +122,20 @@
$.getJSON(url, function (cfg) { $.getJSON(url, function (cfg) {
console.log( cfg ); console.log( cfg );
$("#id").text(cfg["id"]); $("#id").text(cfg["id"]);
var angle = cfg["angle"];
if(angle==0) {
$("#angle").text("Gyro moving");
$("#gravity").text("Gyro moving");
} else {
$("#angle").text(cfg["angle"]); $("#angle").text(cfg["angle"]);
if( cfg["gravity-format"] == "G") if( cfg["gravity-format"] == "G")
$("#gravity").text(cfg["gravity"] + " SG"); $("#gravity").text(cfg["gravity"] + " SG");
else else
$("#gravity").text(cfg["gravity"] + " °P"); $("#gravity").text(cfg["gravity"] + " °P");
}
var batt = cfg["battery"]; var batt = cfg["battery"];
var charge = 0; var charge = 0;

View File

@ -78,7 +78,11 @@ void WebServerHandler::webHandleConfig() {
doc[PARAM_PASS] = ""; // dont show the wifi password doc[PARAM_PASS] = ""; // dont show the wifi password
double angle = myGyro.getAngle(); double angle = 0;
if (myGyro.hasValue())
angle = myGyro.getAngle();
double tempC = myTempSensor.getTempC(myConfig.isGyroTemp()); double tempC = myTempSensor.getTempC(myConfig.isGyroTemp());
double gravity = calculateGravity(angle, tempC); double gravity = calculateGravity(angle, tempC);

View File

@ -1,8 +1,9 @@
{ {
"id": "7376ef", "id": "7376ef",
"angle": 89.86, "angle": 22.4,
"gravity": 1.1052, "gravity": 1.044,
"gravity-tempcorr": 1.1031, "gravity-tempcorr": 1.031,
"gravity-format": "G",
"temp-c": 12, "temp-c": 12,
"temp-f": 32, "temp-f": 32,
"battery": 3.81, "battery": 3.81,