Dismiss ExternalNotification nagging on InkHUD button press (#7056)

* Expose ExternalNotification::isNagging

* Dismiss external notification on button press
This commit is contained in:
todd-herbert 2025-06-16 23:09:55 +12:00 committed by GitHub
parent bd0e25f3f5
commit 465fe18a89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#include "RTC.h"
#include "modules/AdminModule.h"
#include "modules/ExternalNotificationModule.h"
#include "modules/TextMessageModule.h"
#include "sleep.h"
@ -37,6 +38,10 @@ void InkHUD::Events::begin()
void InkHUD::Events::onButtonShort()
{
// Cancel any beeping, buzzing, blinking
// Some button handling suppressed if we are dismissing an external notification (see below)
bool dismissedExt = dismissExternalNotification();
// Check which system applet wants to handle the button press (if any)
SystemApplet *consumer = nullptr;
for (SystemApplet *sa : inkhud->systemApplets) {
@ -49,7 +54,7 @@ void InkHUD::Events::onButtonShort()
// If no system applet is handling input, default behavior instead is to cycle applets
if (consumer)
consumer->onButtonShortPress();
else
else if (!dismissedExt) // Don't change applet if this button press silenced the external notification module
inkhud->nextApplet();
}
@ -204,4 +209,24 @@ int InkHUD::Events::beforeLightSleep(void *unused)
}
#endif
// Silence all ongoing beeping, blinking, buzzing, coming from the external notification module
// Returns true if an external notification was active, and we dismissed it
// Button handling changes depending on our result
bool InkHUD::Events::dismissExternalNotification()
{
// Abort if not using external notifications
if (!moduleConfig.external_notification.enabled)
return false;
// Abort if nothing to dismiss
if (!externalNotificationModule->nagging())
return false;
// Stop the beep buzz blink
externalNotificationModule->stopNow();
// Inform that we did indeed dismiss an external notification
return true;
}
#endif

View File

@ -62,6 +62,9 @@ class Events
CallbackObserver<Events, void *> lightSleepObserver = CallbackObserver<Events, void *>(this, &Events::beforeLightSleep);
#endif
// End any externalNotification beeping, buzzing, blinking etc
bool dismissExternalNotification();
// If set, InkHUD's data will be erased during onReboot
bool eraseOnReboot = false;
};

View File

@ -293,6 +293,12 @@ bool ExternalNotificationModule::getExternal(uint8_t index)
return externalCurrentState[index];
}
// Allow other firmware components to determine whether a notification is ongoing
bool ExternalNotificationModule::nagging()
{
return isNagging;
}
void ExternalNotificationModule::stopNow()
{
rtttl::stop();

View File

@ -40,6 +40,8 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency:
void setMute(bool mute) { isMuted = mute; }
bool getMute() { return isMuted; }
bool nagging();
void stopNow();
void handleGetRingtone(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *response);