Show previous and next message in list.

This commit is contained in:
Balazs Kelemen
2022-01-04 20:41:45 +01:00
parent 7b8849493f
commit 4a29aef19e
3 changed files with 46 additions and 28 deletions

View File

@@ -45,10 +45,18 @@ class CannedMessagePlugin :
void select();
void directionA();
void directionB();
String getCurrentSelection()
String getCurrentMessage()
{
return cannedMessagePluginMessages[this->currentMessageIndex];
}
String getPrevMessage()
{
return cannedMessagePluginMessages[this->getPrevIndex()];
}
String getNextMessage()
{
return cannedMessagePluginMessages[this->getNextIndex()];
}
bool shouldDraw()
{
return currentMessageIndex != -1;
@@ -58,13 +66,37 @@ class CannedMessagePlugin :
virtual int32_t runOnce();
MeshPacket *preparePacket();
void sendText(
NodeNum dest,
const char* message,
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
volatile cannedMessagePluginActionType cwRotationMeaning = ACTION_UP;