Compare commits

...

11 Commits

Author SHA1 Message Date
robertfisk
03d0239d4d
Merge b0f6c616c7 into a5716cf25c 2025-06-03 22:59:53 +02:00
Thomas Göttgens
b0f6c616c7
Merge branch 'master' into CannedMessage_improvements 2025-04-07 09:24:16 +02:00
Thomas Göttgens
e7e6abb229
Merge branch 'master' into CannedMessage_improvements 2025-03-31 11:36:18 +02:00
Thomas Göttgens
9847c82437
Merge branch 'master' into CannedMessage_improvements 2024-10-26 12:23:02 +02:00
Thomas Göttgens
fab843dacb
Merge branch 'master' into CannedMessage_improvements 2024-10-08 10:46:50 +02:00
Thomas Göttgens
1c23e2517f
Merge branch 'master' into CannedMessage_improvements 2024-10-02 23:00:35 +02:00
Ben Meadors
f6bee172fd
Merge branch 'master' into CannedMessage_improvements 2024-09-07 05:58:55 -05:00
Robert Fisk
d983ca5e6c Additional checks for closing Scan&Select canned frame 2024-09-06 15:16:14 +02:00
Robert Fisk
27f00cd156 Improve popup message handling
- Restore old canned message state after displaying message
- Don't clear freetext/state after displaying message
2024-09-06 15:16:14 +02:00
Robert Fisk
21d246ab7c Fix more canned message timeout issues:
- Reliably timout when showing canned message list
- Don't inconsistently clear freetext when scrolling canned message list
2024-09-06 15:16:14 +02:00
Robert Fisk
8e7991606e Improve CannedMessageModule usability
- Don't let Screen timer jump away from CannedMessageModule frame
- Correctly timeout CannedMessageModule with INACTIVATE_AFTER_MS
- Don't reset half-typed messages on timeout
2024-09-06 15:16:14 +02:00
3 changed files with 23 additions and 20 deletions

View File

@ -46,6 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mesh/generated/meshtastic/deviceonly.pb.h" #include "mesh/generated/meshtastic/deviceonly.pb.h"
#include "meshUtils.h" #include "meshUtils.h"
#include "modules/AdminModule.h" #include "modules/AdminModule.h"
#include "modules/CannedMessageModule.h"
#include "modules/ExternalNotificationModule.h" #include "modules/ExternalNotificationModule.h"
#include "modules/TextMessageModule.h" #include "modules/TextMessageModule.h"
#include "modules/WaypointModule.h" #include "modules/WaypointModule.h"
@ -2394,9 +2395,17 @@ void Screen::handleOnPress()
{ {
// If Canned Messages is using the "Scan and Select" input, dismiss the canned message frame when user button is pressed // If Canned Messages is using the "Scan and Select" input, dismiss the canned message frame when user button is pressed
// Minimize impact as a courtesy, as "scan and select" may be used as default config for some boards // Minimize impact as a courtesy, as "scan and select" may be used as default config for some boards
if (scanAndSelectInput != nullptr && scanAndSelectInput->dismissCannedMessageFrame()) // (Fall-through if using auto carousel, to prevent unexpected closing of canned message frame)
if (scanAndSelectInput != nullptr && !config.display.auto_screen_carousel_secs &&
scanAndSelectInput->dismissCannedMessageFrame())
return; return;
// Don't transition away from canned messages if it is active
if (cannedMessageModule->shouldDraw()) {
lastScreenTransition = millis();
return;
}
// If screen was off, just wake it, otherwise advance to next frame // If screen was off, just wake it, otherwise advance to next frame
// If we are in a transition, the press must have bounced, drop it. // If we are in a transition, the press must have bounced, drop it.
if (ui->getUiState()->frameState == FIXED) { if (ui->getUiState()->frameState == FIXED) {

View File

@ -391,12 +391,9 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
if (validEvent) { if (validEvent) {
requestFocus(); // Tell Screen::setFrames to move to our module's frame, next time it runs requestFocus(); // Tell Screen::setFrames to move to our module's frame, next time it runs
// Let runOnce to be called immediately. // Run CannedMessageModule thread now from callee thread context,
if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_SELECT) { // and also schedule it to run later in its own context with the requested delay.
setIntervalFromNow(0); // on fast keypresses, this isn't fast enough. setIntervalFromNow(runOnce());
} else {
runOnce();
}
} }
return 0; return 0;
@ -440,9 +437,13 @@ int32_t CannedMessageModule::runOnce()
if ((this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) || if ((this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) ||
(this->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED) || (this->runState == CANNED_MESSAGE_RUN_STATE_MESSAGE)) { (this->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED) || (this->runState == CANNED_MESSAGE_RUN_STATE_MESSAGE)) {
// TODO: might have some feedback of sending state // TODO: might have some feedback of sending state
this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; if (this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) {
this->restoreOldState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
}
this->runState = this->restoreOldState;
temporaryMessage = ""; temporaryMessage = "";
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen
this->currentMessageIndex = -1; this->currentMessageIndex = -1;
this->freetext = ""; // clear freetext this->freetext = ""; // clear freetext
this->cursor = 0; this->cursor = 0;
@ -454,11 +455,9 @@ int32_t CannedMessageModule::runOnce()
this->notifyObservers(&e); this->notifyObservers(&e);
} else if (((this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT)) && } else if (((this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT)) &&
!Throttle::isWithinTimespanMs(this->lastTouchMillis, INACTIVATE_AFTER_MS)) { !Throttle::isWithinTimespanMs(this->lastTouchMillis, INACTIVATE_AFTER_MS)) {
// Reset module // Don't reset module, just hide the frame
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen
this->currentMessageIndex = -1; this->currentMessageIndex = -1;
this->freetext = ""; // clear freetext
this->cursor = 0;
#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) #if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
@ -511,8 +510,6 @@ int32_t CannedMessageModule::runOnce()
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) { } else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) {
if (this->messagesCount > 0) { if (this->messagesCount > 0) {
this->currentMessageIndex = getPrevIndex(); this->currentMessageIndex = getPrevIndex();
this->freetext = ""; // clear freetext
this->cursor = 0;
#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) #if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
@ -524,8 +521,6 @@ int32_t CannedMessageModule::runOnce()
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) { } else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) {
if (this->messagesCount > 0) { if (this->messagesCount > 0) {
this->currentMessageIndex = this->getNextIndex(); this->currentMessageIndex = this->getNextIndex();
this->freetext = ""; // clear freetext
this->cursor = 0;
#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) #if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD)
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
@ -675,13 +670,9 @@ int32_t CannedMessageModule::runOnce()
if (screen) if (screen)
screen->removeFunctionSymbol("Fn"); screen->removeFunctionSymbol("Fn");
} }
this->lastTouchMillis = millis();
this->notifyObservers(&e);
return INACTIVATE_AFTER_MS;
} }
if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) { if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT || this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) {
this->lastTouchMillis = millis(); this->lastTouchMillis = millis();
this->notifyObservers(&e); this->notifyObservers(&e);
return INACTIVATE_AFTER_MS; return INACTIVATE_AFTER_MS;
@ -765,6 +756,7 @@ void CannedMessageModule::showTemporaryMessage(const String &message)
UIFrameEvent e; UIFrameEvent e;
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen
notifyObservers(&e); notifyObservers(&e);
this->restoreOldState = this->runState;
runState = CANNED_MESSAGE_RUN_STATE_MESSAGE; runState = CANNED_MESSAGE_RUN_STATE_MESSAGE;
// run this loop again in 2 seconds, next iteration will clear the display // run this loop again in 2 seconds, next iteration will clear the display
setIntervalFromNow(2000); setIntervalFromNow(2000);
@ -1156,6 +1148,7 @@ ProcessMessage CannedMessageModule::handleReceived(const meshtastic_MeshPacket &
UIFrameEvent e; UIFrameEvent e;
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen
requestFocus(); // Tell Screen::setFrames that our module's frame should be shown, even if not "first" in the frameset requestFocus(); // Tell Screen::setFrames that our module's frame should be shown, even if not "first" in the frameset
this->restoreOldState = this->runState;
this->runState = CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED; this->runState = CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED;
this->incoming = service->getNodenumFromRequestId(mp.decoded.request_id); this->incoming = service->getNodenumFromRequestId(mp.decoded.request_id);
meshtastic_Routing decoded = meshtastic_Routing_init_default; meshtastic_Routing decoded = meshtastic_Routing_init_default;

View File

@ -138,6 +138,7 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
int currentMessageIndex = -1; int currentMessageIndex = -1;
cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
cannedMessageModuleRunState restoreOldState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
char payload = 0x00; char payload = 0x00;
unsigned int cursor = 0; unsigned int cursor = 0;
String freetext = ""; // Text Buffer for Freetext Editor String freetext = ""; // Text Buffer for Freetext Editor