mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-27 02:14:37 +00:00
Show previous and next message in list.
This commit is contained in:
parent
7b8849493f
commit
4a29aef19e
@ -291,8 +291,12 @@ 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);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
display->drawString(0 + x, 0 + y, cannedMessagePlugin->getPrevMessage());
|
||||||
display->setFont(FONT_MEDIUM);
|
display->setFont(FONT_MEDIUM);
|
||||||
display->drawString(0 + x, 0 + y, cannedMessagePlugin->getCurrentSelection());
|
display->drawString(0 + x, 0 + y + 8, cannedMessagePlugin->getCurrentMessage());
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
display->drawString(0 + x, 0 + y + 24, cannedMessagePlugin->getNextMessage());
|
||||||
|
|
||||||
// the max length of this buffer is much longer than we can possibly print
|
// the max length of this buffer is much longer than we can possibly print
|
||||||
// static char tempBuf[96];
|
// static char tempBuf[96];
|
||||||
|
@ -70,7 +70,7 @@ int32_t CannedMessagePlugin::runOnce()
|
|||||||
{
|
{
|
||||||
this->currentMessageIndex = 0;
|
this->currentMessageIndex = 0;
|
||||||
DEBUG_MSG("First touch. Current message:%s\n",
|
DEBUG_MSG("First touch. Current message:%s\n",
|
||||||
this->getCurrentSelection());
|
this->getCurrentMessage());
|
||||||
}
|
}
|
||||||
else if (this->action == ACTION_PRESSED)
|
else if (this->action == ACTION_PRESSED)
|
||||||
{
|
{
|
||||||
@ -81,41 +81,23 @@ int32_t CannedMessagePlugin::runOnce()
|
|||||||
}
|
}
|
||||||
else if (this->action == ACTION_UP)
|
else if (this->action == ACTION_UP)
|
||||||
{
|
{
|
||||||
if (this->currentMessageIndex <= 0)
|
this->currentMessageIndex = getPrevIndex();
|
||||||
{
|
|
||||||
this->currentMessageIndex =
|
|
||||||
sizeof(cannedMessagePluginMessages) / CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->currentMessageIndex -= 1;
|
|
||||||
}
|
|
||||||
DEBUG_MSG("MOVE UP. Current message:%s\n",
|
DEBUG_MSG("MOVE UP. Current message:%s\n",
|
||||||
this->getCurrentSelection());
|
this->getCurrentMessage());
|
||||||
}
|
}
|
||||||
else if (this->action == ACTION_DOWN)
|
else if (this->action == ACTION_DOWN)
|
||||||
{
|
{
|
||||||
if (this->currentMessageIndex >=
|
this->currentMessageIndex = this->getNextIndex();
|
||||||
(sizeof(cannedMessagePluginMessages) / CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN) - 1)
|
|
||||||
{
|
|
||||||
this->currentMessageIndex = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->currentMessageIndex += 1;
|
|
||||||
}
|
|
||||||
DEBUG_MSG("MOVE DOWN. Current message:%s\n",
|
DEBUG_MSG("MOVE DOWN. Current message:%s\n",
|
||||||
this->getCurrentSelection());
|
this->getCurrentMessage());
|
||||||
}
|
}
|
||||||
if (this->action != ACTION_NONE)
|
if (this->action != ACTION_NONE)
|
||||||
{
|
{
|
||||||
this->action = ACTION_NONE;
|
this->action = ACTION_NONE;
|
||||||
this->notifyObservers(NULL);
|
this->notifyObservers(NULL);
|
||||||
}
|
}
|
||||||
DEBUG_MSG("Current selection index:%d\n",
|
|
||||||
this->currentMessageIndex);
|
|
||||||
|
|
||||||
return 3000;
|
return 30000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CannedMessagePlugin::select()
|
void CannedMessagePlugin::select()
|
||||||
|
@ -45,10 +45,18 @@ class CannedMessagePlugin :
|
|||||||
void select();
|
void select();
|
||||||
void directionA();
|
void directionA();
|
||||||
void directionB();
|
void directionB();
|
||||||
String getCurrentSelection()
|
String getCurrentMessage()
|
||||||
{
|
{
|
||||||
return cannedMessagePluginMessages[this->currentMessageIndex];
|
return cannedMessagePluginMessages[this->currentMessageIndex];
|
||||||
}
|
}
|
||||||
|
String getPrevMessage()
|
||||||
|
{
|
||||||
|
return cannedMessagePluginMessages[this->getPrevIndex()];
|
||||||
|
}
|
||||||
|
String getNextMessage()
|
||||||
|
{
|
||||||
|
return cannedMessagePluginMessages[this->getNextIndex()];
|
||||||
|
}
|
||||||
bool shouldDraw()
|
bool shouldDraw()
|
||||||
{
|
{
|
||||||
return currentMessageIndex != -1;
|
return currentMessageIndex != -1;
|
||||||
@ -58,13 +66,37 @@ class CannedMessagePlugin :
|
|||||||
|
|
||||||
virtual int32_t runOnce();
|
virtual int32_t runOnce();
|
||||||
|
|
||||||
MeshPacket *preparePacket();
|
|
||||||
|
|
||||||
void sendText(
|
void sendText(
|
||||||
NodeNum dest,
|
NodeNum dest,
|
||||||
const char* message,
|
const char* message,
|
||||||
bool wantReplies);
|
bool wantReplies);
|
||||||
|
|
||||||
|
int getNextIndex()
|
||||||
|
{
|
||||||
|
if (this->currentMessageIndex >=
|
||||||
|
(sizeof(cannedMessagePluginMessages) / CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN) - 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this->currentMessageIndex + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPrevIndex()
|
||||||
|
{
|
||||||
|
if (this->currentMessageIndex <= 0)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
sizeof(cannedMessagePluginMessages) / CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this->currentMessageIndex - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: make this configurable
|
// TODO: make this configurable
|
||||||
volatile cannedMessagePluginActionType cwRotationMeaning = ACTION_UP;
|
volatile cannedMessagePluginActionType cwRotationMeaning = ACTION_UP;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user