From d00fda2f4d9cab15ff59f607246c093eb180bedb Mon Sep 17 00:00:00 2001 From: Jason P Date: Fri, 31 Oct 2025 05:55:56 -0500 Subject: [PATCH 1/2] Better implementation of ExternalNotificationModule::stopNow (#8492) * Better implementation of ExternalNotificationModule::stopNow * Label external states turning off * Optimize original code to actually fix issues --- src/modules/ExternalNotificationModule.cpp | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 2b1730e9c..b047e04c2 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -94,22 +94,10 @@ int32_t ExternalNotificationModule::runOnce() // audioThread->isPlaying() also handles actually playing the RTTTL, needs to be called in loop isRtttlPlaying = isRtttlPlaying || audioThread->isPlaying(); #endif - if ((nagCycleCutoff <= millis())) { + if ((nagCycleCutoff < millis()) && !isRtttlPlaying) { // Turn off external notification immediately when timeout is reached, regardless of song state nagCycleCutoff = UINT32_MAX; - LOG_INFO("Turning off external notification: "); - for (int i = 0; i < 3; i++) { - setExternalState(i, false); - externalTurnedOn[i] = 0; - LOG_INFO("%d ", i); - } -#ifdef HAS_I2S - // GPIO0 is used as mclk for I2S audio and set to OUTPUT by the sound library - // T-Deck uses GPIO0 as trackball button, so restore the mode -#if defined(T_DECK) || (defined(BUTTON_PIN) && BUTTON_PIN == 0) - pinMode(0, INPUT); -#endif -#endif + ExternalNotificationModule::stopNow(); isNagging = false; return INT32_MAX; // save cycles till we're needed again } @@ -317,22 +305,33 @@ bool ExternalNotificationModule::nagging() void ExternalNotificationModule::stopNow() { + LOG_INFO("Turning off external notification: "); + LOG_INFO("Stop RTTTL playback"); rtttl::stop(); #ifdef HAS_I2S + LOG_INFO("Stop audioThread playback"); if (audioThread->isPlaying()) audioThread->stop(); #endif - nagCycleCutoff = 1; // small value - isNagging = false; // Turn off all outputs + LOG_INFO("Turning off setExternalStates: "); for (int i = 0; i < 3; i++) { setExternalState(i, false); externalTurnedOn[i] = 0; + LOG_INFO("%d ", i); } setIntervalFromNow(0); #ifdef T_WATCH_S3 drv.stop(); #endif + +#ifdef HAS_I2S + // GPIO0 is used as mclk for I2S audio and set to OUTPUT by the sound library + // T-Deck uses GPIO0 as trackball button, so restore the mode +#if defined(T_DECK) || (defined(BUTTON_PIN) && BUTTON_PIN == 0) + pinMode(0, INPUT); +#endif +#endif } ExternalNotificationModule::ExternalNotificationModule() From 16b1280804f7a85eb59fe4e5994337650c54b3a5 Mon Sep 17 00:00:00 2001 From: Erayd Date: Tue, 28 Oct 2025 00:05:59 +1300 Subject: [PATCH 2/2] Fix type to ensure correct alignment; saves 4B per entry (#8465) --- src/mesh/PacketCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/PacketCache.h b/src/mesh/PacketCache.h index 81ad455da..85660922b 100644 --- a/src/mesh/PacketCache.h +++ b/src/mesh/PacketCache.h @@ -17,7 +17,7 @@ typedef struct PacketCacheEntry { uint8_t encrypted : 1; // Payload is encrypted uint8_t has_metadata : 1; // Payload includes PacketCacheMetadata uint8_t : 6; // Reserved for future use - uint16_t : 8; // Reserved for future use + uint8_t : 8; // Reserved for future use }; }; } PacketCacheEntry;