potential bugfix for nag cutoff

This commit is contained in:
Thomas Göttgens 2022-12-27 21:51:35 +01:00
parent 34f9324766
commit 6f6ca64cfd
3 changed files with 19 additions and 19 deletions

View File

@ -4,7 +4,6 @@
#include "concurrency/OSThread.h" #include "concurrency/OSThread.h"
#include "configuration.h" #include "configuration.h"
#include "graphics/Screen.h" #include "graphics/Screen.h"
#include "modules/ExternalNotificationModule.h"
#include "power.h" #include "power.h"
#include <OneButton.h> #include <OneButton.h>
@ -116,10 +115,6 @@ class ButtonThread : public concurrency::OSThread
{ {
// DEBUG_MSG("press!\n"); // DEBUG_MSG("press!\n");
#ifdef BUTTON_PIN #ifdef BUTTON_PIN
// If a nag notification is running, stop it
if (externalNotificationModule->nagCycleCutoff != UINT32_MAX) {
externalNotificationModule->nagCycleCutoff = 0;
}
if ((BUTTON_PIN != moduleConfig.canned_message.inputbroker_pin_press) || if ((BUTTON_PIN != moduleConfig.canned_message.inputbroker_pin_press) ||
!moduleConfig.canned_message.enabled) { !moduleConfig.canned_message.enabled) {
powerFSM.trigger(EVENT_PRESS); powerFSM.trigger(EVENT_PRESS);

View File

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mesh/Channels.h" #include "mesh/Channels.h"
#include "mesh/generated/deviceonly.pb.h" #include "mesh/generated/deviceonly.pb.h"
#include "modules/TextMessageModule.h" #include "modules/TextMessageModule.h"
#include "modules/ExternalNotificationModule.h"
#include "sleep.h" #include "sleep.h"
#include "target_specific.h" #include "target_specific.h"
#include "utils.h" #include "utils.h"
@ -1070,6 +1071,10 @@ int32_t Screen::runOnce()
handleSetOn(false); handleSetOn(false);
break; break;
case Cmd::ON_PRESS: case Cmd::ON_PRESS:
// If a nag notification is running, stop it
if (externalNotificationModule->nagCycleCutoff != UINT32_MAX) {
externalNotificationModule->nagCycleCutoff = 0;
}
handleOnPress(); handleOnPress();
break; break;
case Cmd::START_BLUETOOTH_PIN_SCREEN: case Cmd::START_BLUETOOTH_PIN_SCREEN:

View File

@ -38,6 +38,20 @@ int32_t ExternalNotificationModule::runOnce()
return INT32_MAX; // we don't need this thread here... return INT32_MAX; // we don't need this thread here...
} else { } else {
if (nagCycleCutoff < millis()) {
nagCycleCutoff = UINT32_MAX;
DEBUG_MSG("Turning off external notification: ");
for (int i = 0; i < 2; i++) {
if (getExternal(i)) {
setExternalOff(i);
externalTurnedOn[i] = 0;
DEBUG_MSG("%d ", i);
}
}
DEBUG_MSG("\n");
return INT32_MAX; // save cycles till we're needed again
}
// If the output is turned on, turn it back off after the given period of time. // If the output is turned on, turn it back off after the given period of time.
if (nagCycleCutoff != UINT32_MAX) { if (nagCycleCutoff != UINT32_MAX) {
if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms
@ -56,20 +70,6 @@ int32_t ExternalNotificationModule::runOnce()
getExternal(2) ? setExternalOff(2) : setExternalOn(2); getExternal(2) ? setExternalOff(2) : setExternalOn(2);
} }
} }
if (nagCycleCutoff < millis()) {
nagCycleCutoff = UINT32_MAX;
DEBUG_MSG("Turning off external notification: ");
for (int i = 0; i < 2; i++) {
if (getExternal(i)) {
setExternalOff(i);
externalTurnedOn[i] = 0;
DEBUG_MSG("%d ", i);
}
}
DEBUG_MSG("\n");
return INT32_MAX; // save cycles till we're needed again
}
return 25; return 25;
} }
} }