diff --git a/docs/api.md b/docs/api.md index e7b4f867..8e69cd5f 100644 --- a/docs/api.md +++ b/docs/api.md @@ -180,7 +180,7 @@ Below are the properties you can utilize in the JSON object. **All keys are opti | `fadeText` | Integer | Fades the text on and off in an given interval, not compatible with gradient or rainbow | N/A | X | X | | `background` | string or array of integers | Sets a background color. | N/A | X | X | | `rainbow` | boolean | Fades each letter in the text differently through the entire RGB spectrum. | false | X | X | -| `icon` | string | The icon ID or filename (without extension) to display on the app. | N/A | X | X | +| `icon` | string | The icon ID or filename (without extension) to display on the app. You can also send a **8x8 jpg** as Base64 String | N/A | X | X | | `pushIcon` | integer | 0 = Icon doesn't move. 1 = Icon moves with text and will not appear again. 2 = Icon moves with text but appears again when the text starts to scroll again. | 0 | X | X | | `repeat` | integer | Sets how many times the text should be scrolled through the matrix before the app ends. | -1 | X | X | | `duration` | integer | Sets how long the app or notification should be displayed. | 5 | X | X | diff --git a/docs/dev.md b/docs/dev.md index c0838195..3d853d63 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -30,4 +30,5 @@ The JSON object has the following properties: | `background_effect` | string | Sets an [effect](https://blueforcer.github.io/awtrix-light/#/effects) as global background layer | - | | `stats_interval` | integer | Sets the interval in milliseconds when awtrix should send its stats to HA and MQTT | 10000 | | `debug_mode` | boolean | Enables serial debug outputs. | false | -| `dfplayer` | boolean | Enables DFPLayer for Awtrix2_conversation builds. | false | \ No newline at end of file +| `dfplayer` | boolean | Enables DFPLayer for Awtrix2_conversation builds. | false | +| `button_callback` | string | http callback url for button presses. | - | \ No newline at end of file diff --git a/src/Globals.cpp b/src/Globals.cpp index c7cd70c1..b8910ab1 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -307,7 +307,7 @@ IPAddress gateway; IPAddress subnet; IPAddress primaryDNS; IPAddress secondaryDNS; -const char *VERSION = "0.90"; +const char *VERSION = "0.91"; String MQTT_HOST = ""; uint16_t MQTT_PORT = 1883; diff --git a/src/MQTTManager.cpp b/src/MQTTManager.cpp index db24106e..fa50fd1c 100644 --- a/src/MQTTManager.cpp +++ b/src/MQTTManager.cpp @@ -482,9 +482,8 @@ void MQTTManager_::sendStats() int freeHeapBytes = ESP.getFreeHeap(); itoa(freeHeapBytes, rambuffer, 10); ram->setValue(rambuffer); - long uptimeValue = PeripheryManager.readUptime(); char uptimeStr[25]; // Buffer for string representation - sprintf(uptimeStr, "%ld", uptimeValue); + sprintf(uptimeStr, "%ld", PeripheryManager.readUptime()); uptime->setValue(uptimeStr); transition->setState(AUTO_TRANSITION, false); ipAddr->setValue(ServerManager.myIP.toString().c_str()); diff --git a/src/PeripheryManager.cpp b/src/PeripheryManager.cpp index ed0bed6f..1828d6fe 100644 --- a/src/PeripheryManager.cpp +++ b/src/PeripheryManager.cpp @@ -506,14 +506,25 @@ void PeripheryManager_::tick() } } -long PeripheryManager_::readUptime() +unsigned long long PeripheryManager_::readUptime() { + static unsigned long lastTime = 0; + static unsigned long long totalElapsed = 0; + unsigned long currentTime = millis(); - unsigned long elapsedTime = currentTime - startTime; - long uptimeSeconds = elapsedTime / 1000; + if (currentTime < lastTime) { + // millis() overflow + totalElapsed += 4294967295UL - lastTime + currentTime + 1; + } else { + totalElapsed += currentTime - lastTime; + } + lastTime = currentTime; + + unsigned long long uptimeSeconds = totalElapsed / 1000; return uptimeSeconds; } + void PeripheryManager_::r2d2(const char *msg) { #ifdef ULANZI diff --git a/src/PeripheryManager.h b/src/PeripheryManager.h index ab700a04..4d261ff0 100644 --- a/src/PeripheryManager.h +++ b/src/PeripheryManager.h @@ -44,7 +44,7 @@ class PeripheryManager_ #ifndef ULANZI void setVolume(uint8_t); #endif - long readUptime(); + unsigned long long readUptime(); }; extern PeripheryManager_ &PeripheryManager;