Skip to content

Commit

Permalink
V0.57
Browse files Browse the repository at this point in the history
- Fixes a bug in colored fragments
- Allows to trigger update manually again
- Adds backgroundcolor to notify and custom apps
  • Loading branch information
Blueforcer committed Apr 18, 2023
1 parent fbc274a commit aa690b8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
3 changes: 2 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ All keys are optional, so you can send just the properties you want to use.
| `textCase` | integer | Changes the Uppercase setting. 0=global setting, 1=forces uppercase; 2=shows as it sent. | 0 |
| `textOffset` | integer | Sets an offset for the x position of a starting text. | 0 |
| `color` | string or array of integers | The text, bar or line color | |
| `background` | string or array of integers | Sets a background color | |
| `rainbow` | boolean | Fades each letter in the text differently through the entire RGB spectrum. | false |
| `icon` | string | The icon ID or filename (without extension) to display on the app. | N/A |
| `pushIcon` | number | 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 |
Expand All @@ -66,7 +67,7 @@ All keys are optional, so you can send just the properties you want to use.
| `progress` | integer | Shows a progressbar. Value can be 0-100 | -1 |
| `progressC` | string or array of integers | The color of the progressbar | -1 |
| `progressBC` | string or array of integers | The color of the progressbar background | -1 |
| `pos` | number | defines the position of your custompage in the loop, starting at 0 for the first position. This will only apply with your first push. You cant change the position afterwards with [this function](api?id=addremove-and-rearange-apps) | N/A |
| `pos` | number | defines the position of your custompage in the loop, starting at 0 for the first position. This will only apply with your first push. You cant change the position afterwards with [this function](api?id=addremove-and-rearange-apps) | N/A |


Color values can have a hex string or an array of R,G,B values:
Expand Down
6 changes: 4 additions & 2 deletions src/Apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct CustomApp
uint8_t textOffset;
int progress = -1;
uint16_t pColor;
uint16_t background = 0;
uint16_t pbColor;
};

Expand Down Expand Up @@ -89,6 +90,7 @@ struct Notification
uint8_t textOffset;
int progress = -1;
uint16_t pColor;
uint16_t background = 0;
uint16_t pbColor;
};

Expand Down Expand Up @@ -351,7 +353,7 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
currentCustomApp = name;

bool hasIcon = ca->icon;

matrix->fillRect(x, y, 32, 8, ca->background);
// Calculate text and available width
uint16_t textWidth = 0;
if (!ca->fragments.empty())
Expand Down Expand Up @@ -578,7 +580,7 @@ void NotifyApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer
bool hasIcon = notify.icon;

// Clear the matrix display
matrix->fillRect(0, 0, 32, 8, 0);
matrix->fillRect(0, 0, 32, 8, notify.background);

// Calculate text and available width
uint16_t textWidth = 0;
Expand Down
19 changes: 13 additions & 6 deletions src/DisplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ bool parseFragmentsText(const String &jsonText, std::vector<uint16_t> &colors, s
uint16_t color;
if (fragmentObj.containsKey("c"))
{
auto fragColor = doc["color"];
auto fragColor = fragmentObj["c"];
color = getColorFromJsonVariant(fragColor, standardColor);
}
else
Expand Down Expand Up @@ -310,6 +310,12 @@ void DisplayManager_::generateCustomPage(const String &name, const char *json)

customApp.progress = doc.containsKey("progress") ? doc["progress"].as<int>() : -1;

if (doc.containsKey("background"))
{
auto background = doc["background"];
customApp.background = getColorFromJsonVariant(background, 0);
}

if (doc.containsKey("progressC"))
{
auto progressC = doc["progressC"];
Expand Down Expand Up @@ -511,6 +517,12 @@ void DisplayManager_::generateNotification(const char *json)
notify.pbColor = matrix->Color(255, 255, 255);
}

if (doc.containsKey("background"))
{
auto background = doc["background"];
notify.background = getColorFromJsonVariant(background, 0);
}

notify.duration = doc.containsKey("duration") ? doc["duration"].as<int>() * 1000 : TIME_PER_APP;
notify.repeat = doc.containsKey("repeat") ? doc["repeat"].as<uint16_t>() : -1;
notify.rainbow = doc.containsKey("rainbow") ? doc["rainbow"].as<bool>() : false;
Expand Down Expand Up @@ -739,7 +751,6 @@ void DisplayManager_::setup()

void checkLifetime()
{
// Sammeln Sie die Namen der zu entfernenden Apps
std::vector<String> appsToRemove;

for (auto it = customApps.begin(); it != customApps.end(); ++it)
Expand All @@ -752,7 +763,6 @@ void checkLifetime()
}
}

// Entfernen Sie die gesammelten Apps nach der Schleife
for (const String &appName : appsToRemove)
{
removeCustomAppFromApps(appName, false);
Expand Down Expand Up @@ -1381,7 +1391,6 @@ void DisplayManager_::setNewSettings(const char *json)
FastLED.setCorrection(COLOR_CORRECTION);
}
}

if (doc.containsKey("CTEMP"))
{
auto colorValue = doc["CTEMP"];
Expand All @@ -1407,7 +1416,6 @@ void DisplayManager_::setNewSettings(const char *json)
FastLED.setTemperature(COLOR_TEMPERATURE);
}
}

if (doc.containsKey("WDCA"))
{
auto WDCA = doc["WDCA"];
Expand All @@ -1418,7 +1426,6 @@ void DisplayManager_::setNewSettings(const char *json)
auto WDCI = doc["WDCI"];
WDC_INACTIVE = getColorFromJsonVariant(WDCI, matrix->Color(120, 120, 120));
}

if (doc.containsKey("TCOL"))
{
auto TCOL = doc["TCOL"];
Expand Down
2 changes: 1 addition & 1 deletion src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ IPAddress gateway;
IPAddress subnet;
IPAddress primaryDNS;
IPAddress secondaryDNS;
const char *VERSION = "0.56";
const char *VERSION = "0.57";
String MQTT_HOST = "";
uint16_t MQTT_PORT = 1883;
String MQTT_USER;
Expand Down
6 changes: 3 additions & 3 deletions src/MQTTManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
}
if (strTopic.equals(MQTT_PREFIX + "/doupdate"))
{
if (UPDATE_AVAILABLE)
if (UpdateManager.checkUpdate(true))
{
UpdateManager.updateFirmware();
}
delete[] payloadCopy;
return;
}
Expand All @@ -221,14 +223,12 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
delete[] payloadCopy;
return;
}

if (strTopic.equals(MQTT_PREFIX + "/reboot"))
{
ESP.restart();
delete[] payloadCopy;
return;
}

if (strTopic.startsWith(MQTT_PREFIX + "/custom"))
{
String topic_str = topic;
Expand Down
6 changes: 4 additions & 2 deletions src/ServerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ void ServerManager_::setup()
mws.addHandler("/api/indicator2", HTTP_POST, []()
{ DisplayManager.indicatorParser(2,mws.webserver->arg("plain").c_str()); mws.webserver->send(200,"OK"); });
mws.addHandler("/api/doupdate", HTTP_POST, []()
{ if (UPDATE_AVAILABLE)
UpdateManager.updateFirmware(); mws.webserver->send(200,"OK"); });
{ mws.webserver->send(200,"OK"); if (UpdateManager.checkUpdate(true))
{
UpdateManager.updateFirmware();
} });
mws.addHandler("/api/power", HTTP_POST, []()
{ DisplayManager.powerStateParse(mws.webserver->arg("plain").c_str()); mws.webserver->send(200,"OK"); });
mws.addHandler("/api/reboot", HTTP_POST, []()
Expand Down
2 changes: 0 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ void setup()
DisplayManager.setup();
DisplayManager.HSVtext(9, 6, VERSION, true, 0);
delay(500);
PeripheryManager.playBootSound();

xTaskCreatePinnedToCore(BootAnimation, "Task", 10000, NULL, 1, &taskHandle, 0);
ServerManager.setup();
if (ServerManager.isConnected)
Expand Down

0 comments on commit aa690b8

Please sign in to comment.