mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-30 06:31:01 +00:00
Show previous and next message in list.
This commit is contained in:
@@ -70,7 +70,7 @@ int32_t CannedMessagePlugin::runOnce()
|
||||
{
|
||||
this->currentMessageIndex = 0;
|
||||
DEBUG_MSG("First touch. Current message:%s\n",
|
||||
this->getCurrentSelection());
|
||||
this->getCurrentMessage());
|
||||
}
|
||||
else if (this->action == ACTION_PRESSED)
|
||||
{
|
||||
@@ -81,41 +81,23 @@ int32_t CannedMessagePlugin::runOnce()
|
||||
}
|
||||
else if (this->action == ACTION_UP)
|
||||
{
|
||||
if (this->currentMessageIndex <= 0)
|
||||
{
|
||||
this->currentMessageIndex =
|
||||
sizeof(cannedMessagePluginMessages) / CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->currentMessageIndex -= 1;
|
||||
}
|
||||
this->currentMessageIndex = getPrevIndex();
|
||||
DEBUG_MSG("MOVE UP. Current message:%s\n",
|
||||
this->getCurrentSelection());
|
||||
this->getCurrentMessage());
|
||||
}
|
||||
else if (this->action == ACTION_DOWN)
|
||||
{
|
||||
if (this->currentMessageIndex >=
|
||||
(sizeof(cannedMessagePluginMessages) / CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_LEN) - 1)
|
||||
{
|
||||
this->currentMessageIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->currentMessageIndex += 1;
|
||||
}
|
||||
this->currentMessageIndex = this->getNextIndex();
|
||||
DEBUG_MSG("MOVE DOWN. Current message:%s\n",
|
||||
this->getCurrentSelection());
|
||||
this->getCurrentMessage());
|
||||
}
|
||||
if (this->action != ACTION_NONE)
|
||||
{
|
||||
this->action = ACTION_NONE;
|
||||
this->notifyObservers(NULL);
|
||||
}
|
||||
DEBUG_MSG("Current selection index:%d\n",
|
||||
this->currentMessageIndex);
|
||||
|
||||
return 3000;
|
||||
return 30000;
|
||||
}
|
||||
|
||||
void CannedMessagePlugin::select()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user