mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 14:42:05 +00:00
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
This commit is contained in:
parent
fd1ebdf363
commit
8e7991606e
@ -45,6 +45,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 "sleep.h"
|
#include "sleep.h"
|
||||||
@ -2317,6 +2318,12 @@ void Screen::handleOnPress()
|
|||||||
if (scanAndSelectInput != nullptr && scanAndSelectInput->dismissCannedMessageFrame())
|
if (scanAndSelectInput != nullptr && 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) {
|
||||||
|
@ -360,12 +360,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;
|
||||||
@ -423,11 +420,8 @@ 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)) &&
|
||||||
((millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS)) {
|
((millis() - 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->freetext = ""; // clear freetext
|
|
||||||
this->cursor = 0;
|
|
||||||
|
|
||||||
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
||||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||||
|
Loading…
Reference in New Issue
Block a user