Skip to content

Commit

Permalink
v0.91
Browse files Browse the repository at this point in the history
- Allows to set a http callback for button presses via dev.json.
- You can send a 8x8 jpg icon as base64 string.
-  Applies gamma correction to brightness control
- IP adress was added to stats
- Fixes a bug where duration wasnt reset after custom app deletion. closes #407
- Indicator fading and blinking options are now disabled after deactivation. closes #402
- Awtrix sends the stats only after the first full sensor reading to avoid zero numbers after boot. closes #391
- Uptime reading now handles the millis() overflow to calculate longer uptime than 49days
- fixes some minor bugs
  • Loading branch information
Blueforcer committed Nov 28, 2023
1 parent 22edc7b commit 8646eb4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
3 changes: 2 additions & 1 deletion docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| `dfplayer` | boolean | Enables DFPLayer for Awtrix2_conversation builds. | false |
| `button_callback` | string | http callback url for button presses. | - |
2 changes: 1 addition & 1 deletion src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/MQTTManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
17 changes: 14 additions & 3 deletions src/PeripheryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/PeripheryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PeripheryManager_
#ifndef ULANZI
void setVolume(uint8_t);
#endif
long readUptime();
unsigned long long readUptime();
};

extern PeripheryManager_ &PeripheryManager;
Expand Down

0 comments on commit 8646eb4

Please sign in to comment.