mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-15 17:42:12 +00:00
Display sending state.
This commit is contained in:
parent
4a29aef19e
commit
b3ddf16d64
@ -290,19 +290,22 @@ static void drawCannedMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *sta
|
|||||||
{
|
{
|
||||||
displayedNodeNum = 0; // Not currently showing a node pane
|
displayedNodeNum = 0; // Not currently showing a node pane
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
if (cannedMessagePlugin->getSendingState() == SENDING_STATE_NONE)
|
||||||
display->setFont(FONT_SMALL);
|
{
|
||||||
display->drawString(0 + x, 0 + y, cannedMessagePlugin->getPrevMessage());
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_MEDIUM);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(0 + x, 0 + y + 8, cannedMessagePlugin->getCurrentMessage());
|
display->drawString(0 + x, 0 + y, cannedMessagePlugin->getPrevMessage());
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_MEDIUM);
|
||||||
display->drawString(0 + x, 0 + y + 24, cannedMessagePlugin->getNextMessage());
|
display->drawString(0 + x, 0 + y + 8, cannedMessagePlugin->getCurrentMessage());
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
// the max length of this buffer is much longer than we can possibly print
|
display->drawString(0 + x, 0 + y + 24, cannedMessagePlugin->getNextMessage());
|
||||||
// static char tempBuf[96];
|
}
|
||||||
// snprintf(tempBuf, sizeof(tempBuf), " %s", mp.decoded.payload.bytes);
|
else
|
||||||
|
{
|
||||||
// display->drawStringMaxWidth(4 + x, 10 + y, SCREEN_WIDTH - (6 + x), tempBuf);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
|
display->setFont(FONT_MEDIUM);
|
||||||
|
display->drawString(display->getWidth()/2 + x, 0 + y + 12, "Sending...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw a series of fields in a column, wrapping to multiple colums if needed
|
/// Draw a series of fields in a column, wrapping to multiple colums if needed
|
||||||
|
@ -51,9 +51,8 @@ void CannedMessagePlugin::sendText(NodeNum dest,
|
|||||||
{
|
{
|
||||||
MeshPacket *p = allocDataPacket();
|
MeshPacket *p = allocDataPacket();
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
const char *replyStr = "This is a canned message";
|
p->decoded.payload.size = strlen(message);
|
||||||
p->decoded.payload.size = strlen(replyStr); // You must specify how many bytes are in the reply
|
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
|
||||||
memcpy(p->decoded.payload.bytes, replyStr, p->decoded.payload.size);
|
|
||||||
|
|
||||||
// PacketId prevPacketId = p->id; // In case we need it later.
|
// PacketId prevPacketId = p->id; // In case we need it later.
|
||||||
|
|
||||||
@ -65,7 +64,13 @@ void CannedMessagePlugin::sendText(NodeNum dest,
|
|||||||
|
|
||||||
int32_t CannedMessagePlugin::runOnce()
|
int32_t CannedMessagePlugin::runOnce()
|
||||||
{
|
{
|
||||||
if ((this->action != ACTION_NONE)
|
if (this->sendingState == SENDING_STATE_ACTIVE)
|
||||||
|
{
|
||||||
|
// TODO: might have some feedback of sendig state
|
||||||
|
this->sendingState = SENDING_STATE_NONE;
|
||||||
|
this->notifyObservers(NULL);
|
||||||
|
}
|
||||||
|
else if ((this->action != ACTION_NONE)
|
||||||
&& (this->currentMessageIndex == -1))
|
&& (this->currentMessageIndex == -1))
|
||||||
{
|
{
|
||||||
this->currentMessageIndex = 0;
|
this->currentMessageIndex = 0;
|
||||||
@ -78,6 +83,9 @@ int32_t CannedMessagePlugin::runOnce()
|
|||||||
NODENUM_BROADCAST,
|
NODENUM_BROADCAST,
|
||||||
cannedMessagePluginMessages[this->currentMessageIndex],
|
cannedMessagePluginMessages[this->currentMessageIndex],
|
||||||
true);
|
true);
|
||||||
|
this->sendingState = SENDING_STATE_ACTIVE;
|
||||||
|
this->currentMessageIndex = -1;
|
||||||
|
return 2000;
|
||||||
}
|
}
|
||||||
else if (this->action == ACTION_UP)
|
else if (this->action == ACTION_UP)
|
||||||
{
|
{
|
||||||
|
@ -15,26 +15,27 @@ enum cannedMessagePluginActionType
|
|||||||
ACTION_DOWN
|
ACTION_DOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum cannedMessagePluginSendigState
|
||||||
|
{
|
||||||
|
SENDING_STATE_NONE,
|
||||||
|
SENDING_STATE_ACTIVE
|
||||||
|
};
|
||||||
|
|
||||||
#define CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN 50
|
#define CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN 50
|
||||||
|
|
||||||
static char cannedMessagePluginMessages[][CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN] =
|
static char cannedMessagePluginMessages[][CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN] =
|
||||||
{
|
{
|
||||||
"I need a helping hand",
|
"Need helping hand",
|
||||||
"I need help with saw",
|
"Help me with saw",
|
||||||
"I need an alpinist",
|
"I need an alpinist",
|
||||||
"I need ambulance",
|
"I need ambulance",
|
||||||
"I'm fine",
|
"I'm fine",
|
||||||
"I'm already waiting",
|
"I'm already waiting",
|
||||||
"I will be late",
|
"I will be late",
|
||||||
"I couldn't join",
|
"I couldn't join",
|
||||||
"We have got company"
|
"We have company"
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _CannedMessagePluginStatus
|
|
||||||
{
|
|
||||||
int dummy;
|
|
||||||
} CannedMessagePluginStatus;
|
|
||||||
|
|
||||||
class CannedMessagePlugin :
|
class CannedMessagePlugin :
|
||||||
public SinglePortPlugin,
|
public SinglePortPlugin,
|
||||||
public Observable<const meshtastic::Status *>,
|
public Observable<const meshtastic::Status *>,
|
||||||
@ -59,7 +60,11 @@ class CannedMessagePlugin :
|
|||||||
}
|
}
|
||||||
bool shouldDraw()
|
bool shouldDraw()
|
||||||
{
|
{
|
||||||
return currentMessageIndex != -1;
|
return (currentMessageIndex != -1) || (this->sendingState != SENDING_STATE_NONE);
|
||||||
|
}
|
||||||
|
cannedMessagePluginSendigState getSendingState()
|
||||||
|
{
|
||||||
|
return this->sendingState;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -106,6 +111,7 @@ class CannedMessagePlugin :
|
|||||||
volatile int rotaryLevelA = LOW;
|
volatile int rotaryLevelA = LOW;
|
||||||
volatile int rotaryLevelB = LOW;
|
volatile int rotaryLevelB = LOW;
|
||||||
int currentMessageIndex = -1;
|
int currentMessageIndex = -1;
|
||||||
|
cannedMessagePluginSendigState sendingState = SENDING_STATE_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CannedMessagePlugin *cannedMessagePlugin;
|
extern CannedMessagePlugin *cannedMessagePlugin;
|
||||||
|
Loading…
Reference in New Issue
Block a user