mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-08 06:35:38 +00:00
Dismiss ExternalNotification nagging on InkHUD button press (#7056)
* Expose ExternalNotification::isNagging * Dismiss external notification on button press
This commit is contained in:
parent
bd0e25f3f5
commit
465fe18a89
@ -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
|
@ -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;
|
||||
};
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user