From 9f46fececb43ef95fa980f544b0e547b27d112b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChl?= <31169771+Blueforcer@users.noreply.github.com> Date: Sun, 30 Apr 2023 23:47:24 +0200 Subject: [PATCH] V0.60 --- src/Apps.h | 21 +++++++-------------- src/DisplayManager.cpp | 22 ++++++++++++++++++++++ src/MQTTManager.cpp | 4 +++- src/MatrixDisplayUi.cpp | 2 +- src/PeripheryManager.cpp | 6 +++--- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/Apps.h b/src/Apps.h index 8b7aa615..d9fb8851 100644 --- a/src/Apps.h +++ b/src/Apps.h @@ -371,16 +371,6 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState return; } - - // reset custom App properties if last frame - if (firstFrame) - { - ca->iconWasPushed = false; - ca->scrollposition = 9 + ca->textOffset; - ca->iconPosition = 0; - ca->scrollDelay = 0; - } - if (!DisplayManager.appIsSwitching) { if (ca->duration > 0) @@ -436,8 +426,7 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState { if (ca->scrollposition <= -textWidth) { - ca->scrollDelay = 0; - ca->scrollposition = 9 + ca->textOffset; + if (ca->iconWasPushed && ca->pushIcon == 2) { ca->iconWasPushed = false; @@ -453,6 +442,8 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState { ++ca->currentRepeat; } + ca->scrollDelay = 0; + ca->scrollposition = 9 + ca->textOffset; } } @@ -460,7 +451,8 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState { if ((ca->scrollDelay > MATRIX_FPS * 1.2) || ((hasIcon ? ca->textOffset + 9 : ca->textOffset) > 31)) { - --ca->scrollposition; + if (state->appState == FIXED) + --ca->scrollposition; } else { @@ -546,7 +538,8 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState { if (ca->iconPosition < 0 && ca->iconWasPushed == false && ca->scrollposition > 8) { - ++ca->iconPosition; + if (state->appState == FIXED) + ++ca->iconPosition; } if (ca->scrollposition < 9 && !ca->iconWasPushed) diff --git a/src/DisplayManager.cpp b/src/DisplayManager.cpp index 7f1c8996..6f9bdfc4 100644 --- a/src/DisplayManager.cpp +++ b/src/DisplayManager.cpp @@ -796,6 +796,26 @@ void DisplayManager_::setup() ui->init(); } +void ResetCustomApps() +{ + if (customApps.empty()) + { + return; + } + + for (auto it = customApps.begin(); it != customApps.end(); ++it) + { + CustomApp &app = it->second; + if (app.name != currentCustomApp) + { + app.iconWasPushed = false; + app.scrollposition = (app.icon ? 9 : 0) + app.textOffset; + app.iconPosition = 0; + app.scrollDelay = 0; + } + } +} + void checkLifetime(uint8_t pos) { if (customApps.empty()) @@ -853,6 +873,7 @@ void DisplayManager_::tick() MQTTManager.setCurrentApp(CURRENT_APP); setAppTime(TIME_PER_APP); checkLifetime(ui->getnextAppNumber()); + ResetCustomApps(); } } @@ -1172,6 +1193,7 @@ void DisplayManager_::updateAppVector(const char *json) { if (appIt != Apps.end()) { + Apps.erase(appIt); } } diff --git a/src/MQTTManager.cpp b/src/MQTTManager.cpp index 63f6e09b..4bad3af5 100644 --- a/src/MQTTManager.cpp +++ b/src/MQTTManager.cpp @@ -51,8 +51,10 @@ void onButtonCommand(HAButton *sender) } else if (sender == doUpdate) { - if (UPDATE_AVAILABLE) + if (UpdateManager.checkUpdate(true)) + { UpdateManager.updateFirmware(); + } } } diff --git a/src/MatrixDisplayUi.cpp b/src/MatrixDisplayUi.cpp index b3d5a91a..b6c4a235 100644 --- a/src/MatrixDisplayUi.cpp +++ b/src/MatrixDisplayUi.cpp @@ -209,7 +209,7 @@ void MatrixDisplayUi::tick() // Revert manuelControll if (this->state.manuelControll) { - this->state.appTransitionDirection = this->lastTransitionDirection; + this->state.appTransitionDirection = 1; this->state.manuelControll = false; } if (this->state.ticksSinceLastStateSwitch >= this->ticksPerApp) diff --git a/src/PeripheryManager.cpp b/src/PeripheryManager.cpp index 44df3462..21b56773 100644 --- a/src/PeripheryManager.cpp +++ b/src/PeripheryManager.cpp @@ -239,11 +239,11 @@ void PeripheryManager_::parseSound(const char *json) void PeripheryManager_::playFromFile(String file) { - if (!SOUND_ACTIVE) return; - DEBUG_PRINTLN(F("Playing RTTTL sound file")); + #ifdef ULANZI + DEBUG_PRINTLN(F("Playing RTTTL sound file")); Melody melody = MelodyFactory.loadRtttlFile("/MELODIES/" + String(file) + ".txt"); player.playAsync(melody); #else @@ -268,7 +268,7 @@ void PeripheryManager_::setup() DEBUG_PRINTLN(F("Setup periphery")); startTime = millis(); pinMode(LDR_PIN, INPUT); -#ifdef awtrix2_upgrade +#ifndef ULANZI dfmp3.begin(); delay(100); setVolume(VOLUME);