Skip to content

Commit

Permalink
fix bug where icons are closed randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
Blueforcer committed Nov 19, 2023
1 parent a0bbf3c commit a2c9d27
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 36 deletions.
6 changes: 3 additions & 3 deletions docs/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Here is a demo, please press the triangle to unfold.
<details>
<summary>Example for adding a Youtube App as NodeRED flow</summary>

```json
```json
[
{
"id": "2a59d30d07abe14f",
Expand Down Expand Up @@ -200,8 +200,8 @@ Here is a demo, please press the triangle to unfold.
"userProps": "",
"sessionExpiry": ""
}
]
```
]
```
</details>

This Node-RED flow retrieves and displays the subscriber count of a specified YouTube channel on an AWTRIX light device. The flow consists of the following nodes:
Expand Down
2 changes: 1 addition & 1 deletion src/Apps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
DisplayManager.getInstance().resetTextColor();
}

// Unattractive to have a function for every customapp which does the same, but currently still no other option found TODO
// Unattractive to have a function for every customapp wich does the same, but currently still no other option found TODO

void CApp1(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, int16_t y, GifPlayer *gifPlayer)
{
Expand Down
6 changes: 0 additions & 6 deletions src/ArtnetWifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ class ArtnetWifi
physical = port;
}

[[deprecated]]
inline void setPhysical(uint8_t port)
{
setPhysical(port);
}

inline uint16_t getLength(void)
{
return dmxDataLength;
Expand Down
41 changes: 15 additions & 26 deletions src/DisplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ void DisplayManager_::applyAllSettings()
setAutoTransition(AUTO_TRANSITION);
}

void DisplayManager_::setAppTime(long duration)
{
ui->setTimePerApp(duration);
}

void DisplayManager_::resetTextColor()
{
setTextColor(TEXTCOLOR_888);
Expand Down Expand Up @@ -385,6 +390,7 @@ void removeCustomAppFromApps(const String &name, bool setApps)
ui->setApps(Apps);
DisplayManager.getInstance().setAutoTransition(true);
deleteCustomAppFile(name);
DisplayManager.setAppTime(TIME_PER_APP);
}

bool parseFragmentsText(const JsonArray &fragmentArray, std::vector<uint32_t> &colors, std::vector<String> &fragments, uint32_t standardColor)
Expand Down Expand Up @@ -613,35 +619,24 @@ bool DisplayManager_::generateCustomPage(const String &name, JsonObject doc, boo

if (doc.containsKey("icon"))
{
String iconValue = doc["icon"].as<String>();
String newIconName = doc["icon"].as<String>();

if (iconValue.endsWith("="))
if (newIconName.endsWith("="))
{
customApp.jpegDataSize = decode_base64((const unsigned char *)iconValue.c_str(), customApp.jpegDataBuffer);
customApp.jpegDataSize = decode_base64((const unsigned char *)newIconName.c_str(), customApp.jpegDataBuffer);
customApp.isGif = false;
customApp.icon.close();
customApp.iconName = "";
customApp.iconPosition = 0;
customApp.currentFrame = 0;
}
else
else if (customApp.iconName != newIconName)
{
customApp.jpegDataSize = 0;
if (customApp.iconName != iconValue)
{
customApp.iconName = iconValue;
customApp.icon.close();
customApp.iconPosition = 0;
customApp.currentFrame = 0;
}

else
{
customApp.icon.close();
customApp.iconName = "";
customApp.iconPosition = 0;
customApp.currentFrame = 0;
}
customApp.iconName = newIconName;
customApp.icon.close();
customApp.iconPosition = 0;
customApp.currentFrame = 0;
}
}
else
Expand Down Expand Up @@ -906,7 +901,6 @@ bool DisplayManager_::generateNotification(uint8_t source, const char *json)
{
String iconValue = doc["icon"].as<String>();


if (iconValue.endsWith("="))
{
newNotification.jpegDataSize = decode_base64((const unsigned char *)iconValue.c_str(), newNotification.jpegDataBuffer);
Expand Down Expand Up @@ -1222,7 +1216,7 @@ void DisplayManager_::tick()
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t *data)
{
sendFrame = 1;
// set brightness of the whole strip
// set brightness of the whole matrix
if (universe == 10)
{
matrix->setBrightness(data[0]);
Expand Down Expand Up @@ -1595,11 +1589,6 @@ String DisplayManager_::getStats()
return jsonString;
}

void DisplayManager_::setAppTime(long duration)
{
ui->setTimePerApp(duration);
}

void DisplayManager_::setMatrixLayout(int layout)
{
delete matrix; // Free memory from the current matrix object
Expand Down

0 comments on commit a2c9d27

Please sign in to comment.