From a6bff7287e1c9747ecf9aaa7652482a32b75a39c Mon Sep 17 00:00:00 2001 From: Magnus Persson Date: Tue, 2 Aug 2022 13:02:01 +0200 Subject: [PATCH] Added "not found" messages for gyro/temp sensor. --- html/index.htm | 18 +++++++++++++----- html/index.min.htm | 2 +- src/webserver.cpp | 8 ++++++-- src_docs/source/releases.rst | 2 ++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/html/index.htm b/html/index.htm index 8353595..fda4af7 100644 --- a/html/index.htm +++ b/html/index.htm @@ -300,7 +300,11 @@ var angle = cfg["angle"]; - if(angle==0) { + if(angle==-1) { + showError("Unable to connect to gyro, try a reset or power off/on") + $("#angle").text("No gyro"); + $("#gravity").text("No gyro"); + } else if(angle==0) { $("#angle").text("Gyro moving"); $("#gravity").text("Gyro moving"); } else { @@ -329,10 +333,14 @@ $("#battery").text(batt + " V (" + charge + "%)" ); - if( cfg["temp-format"] == "C") - $("#temp").text(cfg["temp-c"] + " C"); - else - $("#temp").text(cfg["temp-f"] + " F"); + if( cfg["temp-c"] == -273) { + $("#temp").text("No temp sensor"); + } else { + if( cfg["temp-format"] == "C") + $("#temp").text(cfg["temp-c"] + " C"); + else + $("#temp").text(cfg["temp-f"] + " F"); + } if( cfg["sleep-mode"] ) $("#sleep-mode").attr("checked", true ); diff --git a/html/index.min.htm b/html/index.min.htm index d3e013c..08f5351 100644 --- a/html/index.min.htm +++ b/html/index.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

Gravity:
Loading...
Temperature:
Loading...
Angle/Tilt:
Loading...
Battery:
Loading...
Average runtime:
Loading...

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...
Platform:
Loading...
SSID:
Loading...
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Gravity:
Loading...
Temperature:
Loading...
Angle/Tilt:
Loading...
Battery:
Loading...
Average runtime:
Loading...

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...
Platform:
Loading...
SSID:
Loading...
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/src/webserver.cpp b/src/webserver.cpp index 46a3fc5..2e05aaa 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -332,9 +332,13 @@ void WebServerHandler::webHandleStatus() { DynamicJsonDocument doc(500); - double angle = 0; + double angle = 0; // Indicate we have no valid gyro value - if (myGyro.hasValue()) angle = myGyro.getAngle(); + if (myGyro.isConnected()) { + if (myGyro.hasValue()) angle = myGyro.getAngle(); + } else { + angle = -1; // Indicate that we have no connection to gyro + } double tempC = myTempSensor.getTempC(myConfig.isGyroTemp()); double gravity = calculateGravity(angle, tempC); diff --git a/src_docs/source/releases.rst b/src_docs/source/releases.rst index 5673dfc..4f9cd46 100644 --- a/src_docs/source/releases.rst +++ b/src_docs/source/releases.rst @@ -17,6 +17,8 @@ Documentation User interface ++++++++++++++ +* (beta3) Added error message to user message if gyro connection fails. +* (beta3) Added message to user message if no temp sensor can be found. * (beta3) Added drop down menus in user interface to simplify navigation to sub pages * (beta3) Changed behavior for Home Assistant Device registration, this is only done when format template is saved, during normal operation only data values are posted on MQTT. * (beta2) Calibration temperature (for temp adjustment) can now be set under advanced settings.