diff --git a/html/device.htm b/html/device.htm index 3043bd5..a2dee49 100644 --- a/html/device.htm +++ b/html/device.htm @@ -88,6 +88,14 @@
Device ID:
Loading...
+
+
Battery voltage:
+
Loading...
+
+
+
Average runtime:
+
Loading...
+

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...
Battery voltage:
Loading...
Average runtime:
Loading...

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/src/helper.cpp b/src/helper.cpp index 4bbfc20..13187fd 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -111,8 +111,6 @@ FloatHistoryLog::FloatHistoryLog(String fName) { _fName = fName; File runFile = LittleFS.open(_fName, "r"); - int i = 0; - if (runFile) { for(int i = 0; i<10; i++) { _runTime[i] = runFile.readStringUntil('\n').toFloat(); diff --git a/src/resources.hpp b/src/resources.hpp index 3431c1f..b95a1d6 100644 --- a/src/resources.hpp +++ b/src/resources.hpp @@ -30,6 +30,7 @@ SOFTWARE. #define PARAM_OTA "ota-url" #define PARAM_SSID "wifi-ssid" #define PARAM_PASS "wifi-pass" +#define PARAM_RUNTIME_AVERAGE "runtime-average" #define PARAM_PUSH_BREWFATHER "brewfather-push" #define PARAM_PUSH_HTTP "http-push" #define PARAM_PUSH_HTTP_H1 "http-push-h1" diff --git a/src/webserver.cpp b/src/webserver.cpp index a7c11b3..2c10c63 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -50,6 +50,11 @@ void WebServerHandler::webHandleDevice() { doc[PARAM_APP_NAME] = CFG_APPNAME; doc[PARAM_APP_VER] = CFG_APPVER; doc[PARAM_MDNS] = myConfig.getMDNS(); + doc[PARAM_BATTERY] = reduceFloatPrecision(myBatteryVoltage.getVoltage()); + + FloatHistoryLog runLog(RUNTIME_FILENAME); + doc[PARAM_RUNTIME_AVERAGE] = reduceFloatPrecision(runLog.getAverage()?runLog.getAverage()/1000:0, 1); + #if LOG_LEVEL == 6 serializeJson(doc, Serial); Serial.print(CR); diff --git a/src_docs/source/api.rst b/src_docs/source/api.rst index e066dd2..90cccdc 100644 --- a/src_docs/source/api.rst +++ b/src_docs/source/api.rst @@ -69,7 +69,9 @@ Retrive the current device settings via an HTTP GET command. Payload is in JSON "app-name": "GravityMon", "app-ver": "0.0.0", "id": "ee1bfc", - "mdns": "gravmon" + "mdns": "gravmon", + "battery": 3.89, + "runtime-average": 3.12 } diff --git a/test/device.json b/test/device.json index ea87d67..e4eb5a2 100644 --- a/test/device.json +++ b/test/device.json @@ -2,5 +2,7 @@ "app-name": "GravityMon ", "app-ver": "0.0.0", "id": "7376ef", - "mdns": "gravmon" + "mdns": "gravmon", + "battery": 3.89, + "runtime-average": 3.12 } \ No newline at end of file