mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-30 02:15:41 +00:00
Merge 648808405a
into 1a8ab2aadc
This commit is contained in:
commit
a6fac5bdb7
@ -40,6 +40,9 @@ extern ScanI2C::DeviceAddress cardkb_found;
|
|||||||
extern bool graphics::isMuted;
|
extern bool graphics::isMuted;
|
||||||
|
|
||||||
static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto";
|
static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto";
|
||||||
|
static NodeNum lastDest = NODENUM_BROADCAST;
|
||||||
|
static uint8_t lastChannel = 0;
|
||||||
|
static bool lastDestSet = false;
|
||||||
|
|
||||||
meshtastic_CannedMessageModuleConfig cannedMessageModuleConfig;
|
meshtastic_CannedMessageModuleConfig cannedMessageModuleConfig;
|
||||||
|
|
||||||
@ -63,8 +66,18 @@ CannedMessageModule::CannedMessageModule()
|
|||||||
|
|
||||||
void CannedMessageModule::LaunchWithDestination(NodeNum newDest, uint8_t newChannel)
|
void CannedMessageModule::LaunchWithDestination(NodeNum newDest, uint8_t newChannel)
|
||||||
{
|
{
|
||||||
|
// Use the requested destination, unless it's "broadcast" and we have a previous node/channel
|
||||||
|
if (newDest == NODENUM_BROADCAST && lastDestSet) {
|
||||||
|
newDest = lastDest;
|
||||||
|
newChannel = lastChannel;
|
||||||
|
}
|
||||||
dest = newDest;
|
dest = newDest;
|
||||||
channel = newChannel;
|
channel = newChannel;
|
||||||
|
lastDest = dest;
|
||||||
|
lastChannel = channel;
|
||||||
|
lastDestSet = true;
|
||||||
|
|
||||||
|
// Rest of function unchanged...
|
||||||
// Always select the first real canned message on activation
|
// Always select the first real canned message on activation
|
||||||
int firstRealMsgIdx = 0;
|
int firstRealMsgIdx = 0;
|
||||||
for (int i = 0; i < messagesCount; ++i) {
|
for (int i = 0; i < messagesCount; ++i) {
|
||||||
@ -84,10 +97,28 @@ void CannedMessageModule::LaunchWithDestination(NodeNum newDest, uint8_t newChan
|
|||||||
notifyObservers(&e);
|
notifyObservers(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CannedMessageModule::LaunchRepeatDestination()
|
||||||
|
{
|
||||||
|
if (!lastDestSet) {
|
||||||
|
LaunchWithDestination(NODENUM_BROADCAST, 0);
|
||||||
|
} else {
|
||||||
|
LaunchWithDestination(lastDest, lastChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CannedMessageModule::LaunchFreetextWithDestination(NodeNum newDest, uint8_t newChannel)
|
void CannedMessageModule::LaunchFreetextWithDestination(NodeNum newDest, uint8_t newChannel)
|
||||||
{
|
{
|
||||||
|
// Use the requested destination, unless it's "broadcast" and we have a previous node/channel
|
||||||
|
if (newDest == NODENUM_BROADCAST && lastDestSet) {
|
||||||
|
newDest = lastDest;
|
||||||
|
newChannel = lastChannel;
|
||||||
|
}
|
||||||
dest = newDest;
|
dest = newDest;
|
||||||
channel = newChannel;
|
channel = newChannel;
|
||||||
|
lastDest = dest;
|
||||||
|
lastChannel = channel;
|
||||||
|
lastDestSet = true;
|
||||||
|
|
||||||
runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
||||||
requestFocus();
|
requestFocus();
|
||||||
UIFrameEvent e;
|
UIFrameEvent e;
|
||||||
@ -479,6 +510,9 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
|
|||||||
if (destIndex < static_cast<int>(activeChannelIndices.size())) {
|
if (destIndex < static_cast<int>(activeChannelIndices.size())) {
|
||||||
dest = NODENUM_BROADCAST;
|
dest = NODENUM_BROADCAST;
|
||||||
channel = activeChannelIndices[destIndex];
|
channel = activeChannelIndices[destIndex];
|
||||||
|
lastDest = dest;
|
||||||
|
lastChannel = channel;
|
||||||
|
lastDestSet = true;
|
||||||
} else {
|
} else {
|
||||||
int nodeIndex = destIndex - static_cast<int>(activeChannelIndices.size());
|
int nodeIndex = destIndex - static_cast<int>(activeChannelIndices.size());
|
||||||
if (nodeIndex >= 0 && nodeIndex < static_cast<int>(filteredNodes.size())) {
|
if (nodeIndex >= 0 && nodeIndex < static_cast<int>(filteredNodes.size())) {
|
||||||
@ -486,6 +520,10 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
|
|||||||
if (selectedNode) {
|
if (selectedNode) {
|
||||||
dest = selectedNode->num;
|
dest = selectedNode->num;
|
||||||
channel = selectedNode->channel;
|
channel = selectedNode->channel;
|
||||||
|
// Already saves here, but for clarity, also:
|
||||||
|
lastDest = dest;
|
||||||
|
lastChannel = channel;
|
||||||
|
lastDestSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -827,6 +865,9 @@ int CannedMessageModule::handleEmotePickerInput(const InputEvent *event)
|
|||||||
|
|
||||||
void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const char *message, bool wantReplies)
|
void CannedMessageModule::sendText(NodeNum dest, ChannelIndex channel, const char *message, bool wantReplies)
|
||||||
{
|
{
|
||||||
|
lastDest = dest;
|
||||||
|
lastChannel = channel;
|
||||||
|
lastDestSet = true;
|
||||||
// === Prepare packet ===
|
// === Prepare packet ===
|
||||||
meshtastic_MeshPacket *p = allocDataPacket();
|
meshtastic_MeshPacket *p = allocDataPacket();
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
|
@ -59,6 +59,7 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
|
|||||||
CannedMessageModule();
|
CannedMessageModule();
|
||||||
|
|
||||||
void LaunchWithDestination(NodeNum, uint8_t newChannel = 0);
|
void LaunchWithDestination(NodeNum, uint8_t newChannel = 0);
|
||||||
|
void LaunchRepeatDestination();
|
||||||
void LaunchFreetextWithDestination(NodeNum, uint8_t newChannel = 0);
|
void LaunchFreetextWithDestination(NodeNum, uint8_t newChannel = 0);
|
||||||
|
|
||||||
// === Emote Picker navigation ===
|
// === Emote Picker navigation ===
|
||||||
|
Loading…
Reference in New Issue
Block a user