mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-19 03:22:07 +00:00
Bugfixes in Freetext Module.
- work without fixed messages defined - honour cursor position on backspace - don't send an empty string - compiler warnings in font engine fixed
This commit is contained in:
parent
b73e240f4d
commit
011db443ba
@ -228,11 +228,13 @@ class Screen : public concurrency::OSThread
|
|||||||
SKIPREST = false;
|
SKIPREST = false;
|
||||||
if (ch == 129) return (uint8_t)(168); // Ё
|
if (ch == 129) return (uint8_t)(168); // Ё
|
||||||
if (ch > 143 && ch < 192) return (uint8_t)(ch + 48);
|
if (ch > 143 && ch < 192) return (uint8_t)(ch + 48);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case 0xD1: {
|
case 0xD1: {
|
||||||
SKIPREST = false;
|
SKIPREST = false;
|
||||||
if (ch == 145) return (uint8_t)(184); // ё
|
if (ch == 145) return (uint8_t)(184); // ё
|
||||||
if (ch > 127 && ch < 144) return (uint8_t)(ch + 112);
|
if (ch > 127 && ch < 144) return (uint8_t)(ch + 112);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
// Remove Canned message screen if no action is taken for some milliseconds
|
// Remove Canned message screen if no action is taken for some milliseconds
|
||||||
#define INACTIVATE_AFTER_MS 20000
|
#define INACTIVATE_AFTER_MS 20000
|
||||||
|
|
||||||
|
extern uint8_t cardkb_found;
|
||||||
|
|
||||||
static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto";
|
static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto";
|
||||||
|
|
||||||
CannedMessageModuleConfig cannedMessageModuleConfig;
|
CannedMessageModuleConfig cannedMessageModuleConfig;
|
||||||
@ -50,7 +52,7 @@ CannedMessageModule::CannedMessageModule()
|
|||||||
{
|
{
|
||||||
if (moduleConfig.canned_message.enabled) {
|
if (moduleConfig.canned_message.enabled) {
|
||||||
this->loadProtoForModule();
|
this->loadProtoForModule();
|
||||||
if (this->splitConfiguredMessages() <= 0) {
|
if ((this->splitConfiguredMessages() <= 0) && (cardkb_found != CARDKB_ADDR)) {
|
||||||
DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n");
|
DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n");
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
|
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
|
||||||
} else {
|
} else {
|
||||||
@ -215,7 +217,7 @@ 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)) && (millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS) {
|
} else if (((this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT)) && (millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS) {
|
||||||
// Reset module
|
// Reset module
|
||||||
DEBUG_MSG("Reset due the lack of activity.\n");
|
DEBUG_MSG("Reset due to lack of activity.\n");
|
||||||
e.frameChanged = true;
|
e.frameChanged = true;
|
||||||
this->currentMessageIndex = -1;
|
this->currentMessageIndex = -1;
|
||||||
this->freetext = ""; // clear freetext
|
this->freetext = ""; // clear freetext
|
||||||
@ -224,11 +226,24 @@ int32_t CannedMessageModule::runOnce()
|
|||||||
this->notifyObservers(&e);
|
this->notifyObservers(&e);
|
||||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_SELECT) {
|
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_SELECT) {
|
||||||
if (this->payload == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
|
if (this->payload == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
|
||||||
|
if (this->freetext.length() > 0) {
|
||||||
sendText(NODENUM_BROADCAST, this->freetext.c_str(), true);
|
sendText(NODENUM_BROADCAST, this->freetext.c_str(), true);
|
||||||
} else {
|
|
||||||
sendText(NODENUM_BROADCAST, this->messages[this->currentMessageIndex], true);
|
|
||||||
}
|
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
|
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Reset message is empty.\n");
|
||||||
|
this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||||
|
e.frameChanged = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (strlen(this->messages[this->currentMessageIndex]) > 0) {
|
||||||
|
sendText(NODENUM_BROADCAST, this->messages[this->currentMessageIndex], true);
|
||||||
|
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Reset message is empty.\n");
|
||||||
|
this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||||
|
e.frameChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
this->currentMessageIndex = -1;
|
this->currentMessageIndex = -1;
|
||||||
this->freetext = ""; // clear freetext
|
this->freetext = ""; // clear freetext
|
||||||
this->cursor = 0;
|
this->cursor = 0;
|
||||||
@ -266,7 +281,11 @@ int32_t CannedMessageModule::runOnce()
|
|||||||
break;
|
break;
|
||||||
case 8: // backspace
|
case 8: // backspace
|
||||||
if (this->freetext.length() > 0) {
|
if (this->freetext.length() > 0) {
|
||||||
|
if(this->cursor == this->freetext.length()) {
|
||||||
this->freetext = this->freetext.substring(0, this->freetext.length() - 1);
|
this->freetext = this->freetext.substring(0, this->freetext.length() - 1);
|
||||||
|
} else {
|
||||||
|
this->freetext = this->freetext.substring(0, this->cursor - 1) + this->freetext.substring(this->cursor, this->freetext.length());
|
||||||
|
}
|
||||||
this->cursor--;
|
this->cursor--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user