mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-06 21:54:44 +00:00
Unified header for sending.
This commit is contained in:
parent
53f2f615b2
commit
ea9c71ecd9
@ -138,6 +138,21 @@ int CannedMessageModule::splitConfiguredMessages()
|
|||||||
|
|
||||||
return this->messagesCount;
|
return this->messagesCount;
|
||||||
}
|
}
|
||||||
|
void CannedMessageModule::drawHeader(OLEDDisplay *display, int16_t x, int16_t y, char* buffer) {
|
||||||
|
if (display->getWidth() > 128) {
|
||||||
|
if (this->dest == NODENUM_BROADCAST) {
|
||||||
|
display->drawStringf(x, y, buffer, "To: Broadcast@%s", channels.getName(this->channel));
|
||||||
|
} else {
|
||||||
|
display->drawStringf(x, y, buffer, "To: %s@%s", getNodeName(this->dest), channels.getName(this->channel));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this->dest == NODENUM_BROADCAST) {
|
||||||
|
display->drawStringf(x, y, buffer, "To: Broadc@%.5s", channels.getName(this->channel));
|
||||||
|
} else {
|
||||||
|
display->drawStringf(x, y, buffer, "To: %.5s@%.5s", getNodeName(this->dest), channels.getName(this->channel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CannedMessageModule::resetSearch() {
|
void CannedMessageModule::resetSearch() {
|
||||||
LOG_INFO("Resetting search, restoring full destination list");
|
LOG_INFO("Resetting search, restoring full destination list");
|
||||||
@ -1560,33 +1575,17 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
if (this->destSelect != CANNED_MESSAGE_DESTINATION_TYPE_NONE) {
|
// --- Draw node/channel header at the top ---
|
||||||
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
drawHeader(display, x, y, buffer);
|
||||||
display->setColor(BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (this->destSelect) {
|
|
||||||
case CANNED_MESSAGE_DESTINATION_TYPE_NODE:
|
|
||||||
display->drawStringf(0 + x, 0 + y, buffer, "To: >%s<@%s", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
break;
|
|
||||||
case CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL:
|
|
||||||
display->drawStringf(0 + x, 0 + y, buffer, "To: %s@>%s<", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (display->getWidth() > 128) {
|
|
||||||
display->drawStringf(0 + x, 0 + y, buffer, "To: %s@%s", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
} else {
|
|
||||||
display->drawStringf(0 + x, 0 + y, buffer, "To: %.5s@%.5s", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// --- Char count right-aligned ---
|
||||||
if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NONE) {
|
if (this->destSelect == CANNED_MESSAGE_DESTINATION_TYPE_NONE) {
|
||||||
uint16_t charsLeft = meshtastic_Constants_DATA_PAYLOAD_LEN - this->freetext.length() - (moduleConfig.canned_message.send_bell ? 1 : 0);
|
uint16_t charsLeft = meshtastic_Constants_DATA_PAYLOAD_LEN - this->freetext.length() - (moduleConfig.canned_message.send_bell ? 1 : 0);
|
||||||
snprintf(buffer, sizeof(buffer), "%d left", charsLeft);
|
snprintf(buffer, sizeof(buffer), "%d left", charsLeft);
|
||||||
display->drawString(x + display->getWidth() - display->getStringWidth(buffer), y + 0, buffer);
|
display->drawString(x + display->getWidth() - display->getStringWidth(buffer), y + 0, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Draw Free Text input, shifted down ---
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
display->drawStringMaxWidth(0 + x, 0 + y + FONT_HEIGHT_SMALL, x + display->getWidth(),
|
display->drawStringMaxWidth(0 + x, 0 + y + FONT_HEIGHT_SMALL, x + display->getWidth(),
|
||||||
drawWithCursor(this->freetext, this->cursor));
|
drawWithCursor(this->freetext, this->cursor));
|
||||||
@ -1602,21 +1601,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
const int rowSpacing = FONT_HEIGHT_SMALL - 4;
|
const int rowSpacing = FONT_HEIGHT_SMALL - 4;
|
||||||
|
|
||||||
// Draw header (To: ...)
|
// Draw header (To: ...)
|
||||||
switch (this->destSelect) {
|
drawHeader(display, x, y, buffer);
|
||||||
case CANNED_MESSAGE_DESTINATION_TYPE_NODE:
|
|
||||||
display->drawStringf(x + 0, y + 0, buffer, "To: >%s<@%s", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
break;
|
|
||||||
case CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL:
|
|
||||||
display->drawStringf(x + 0, y + 0, buffer, "To: %s@>%s<", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (display->getWidth() > 128) {
|
|
||||||
display->drawStringf(x + 0, y + 0, buffer, "To: %s@%s", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
} else {
|
|
||||||
display->drawStringf(x + 0, y + 0, buffer, "To: %.5s@%.5s", getNodeName(this->dest), channels.getName(this->channel));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shift message list upward by 3 pixels to reduce spacing between header and first message
|
// Shift message list upward by 3 pixels to reduce spacing between header and first message
|
||||||
const int listYOffset = y + FONT_HEIGHT_SMALL - 3;
|
const int listYOffset = y + FONT_HEIGHT_SMALL - 3;
|
||||||
|
@ -24,7 +24,6 @@ enum cannedMessageModuleRunState {
|
|||||||
enum cannedMessageDestinationType {
|
enum cannedMessageDestinationType {
|
||||||
CANNED_MESSAGE_DESTINATION_TYPE_NONE,
|
CANNED_MESSAGE_DESTINATION_TYPE_NONE,
|
||||||
CANNED_MESSAGE_DESTINATION_TYPE_NODE,
|
CANNED_MESSAGE_DESTINATION_TYPE_NODE,
|
||||||
CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CannedMessageModuleIconType { shift, backspace, space, enter };
|
enum CannedMessageModuleIconType { shift, backspace, space, enter };
|
||||||
@ -102,6 +101,7 @@ protected:
|
|||||||
|
|
||||||
// === Transmission ===
|
// === Transmission ===
|
||||||
void sendText(NodeNum dest, ChannelIndex channel, const char *message, bool wantReplies);
|
void sendText(NodeNum dest, ChannelIndex channel, const char *message, bool wantReplies);
|
||||||
|
void drawHeader(OLEDDisplay *display, int16_t x, int16_t y, char* buffer);
|
||||||
int splitConfiguredMessages();
|
int splitConfiguredMessages();
|
||||||
int getNextIndex();
|
int getNextIndex();
|
||||||
int getPrevIndex();
|
int getPrevIndex();
|
||||||
@ -162,8 +162,6 @@ private:
|
|||||||
NodeNum incoming = NODENUM_BROADCAST; // Source node from which last ACK/NACK was received
|
NodeNum incoming = NODENUM_BROADCAST; // Source node from which last ACK/NACK was received
|
||||||
NodeNum lastSentNode = 0; // Tracks the most recent node we sent a message to (for UI display)
|
NodeNum lastSentNode = 0; // Tracks the most recent node we sent a message to (for UI display)
|
||||||
ChannelIndex channel = 0; // Channel index used when sending a message
|
ChannelIndex channel = 0; // Channel index used when sending a message
|
||||||
uint8_t numChannels = 0; // Total number of channels available for selection
|
|
||||||
ChannelIndex indexChannels[MAX_NUM_CHANNELS] = {0}; // Cached channel indices available for this node
|
|
||||||
|
|
||||||
bool ack = false; // True = ACK received, False = NACK or failed
|
bool ack = false; // True = ACK received, False = NACK or failed
|
||||||
bool waitingForAck = false; // True if we're expecting an ACK and should monitor routing packets
|
bool waitingForAck = false; // True if we're expecting an ACK and should monitor routing packets
|
||||||
|
Loading…
Reference in New Issue
Block a user