mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-13 22:32:27 +00:00
Merge pull request #8907 from mtoolstec/multi-message-storage
Multi message storage supports on UpDown Endoer device
This commit is contained in:
@@ -1656,6 +1656,26 @@ int Screen::handleInputEvent(const InputEvent *event)
|
||||
|
||||
// If no modules are using the input, move between frames
|
||||
if (!inputIntercepted) {
|
||||
#if defined(INPUTDRIVER_ENCODER_TYPE) && INPUTDRIVER_ENCODER_TYPE == 2
|
||||
bool handledEncoderScroll = false;
|
||||
const bool isTextMessageFrame = (framesetInfo.positions.textMessage != 255 &&
|
||||
this->ui->getUiState()->currentFrame == framesetInfo.positions.textMessage &&
|
||||
!messageStore.getMessages().empty());
|
||||
if (isTextMessageFrame) {
|
||||
if (event->inputEvent == INPUT_BROKER_UP_LONG) {
|
||||
graphics::MessageRenderer::nudgeScroll(-1);
|
||||
handledEncoderScroll = true;
|
||||
} else if (event->inputEvent == INPUT_BROKER_DOWN_LONG) {
|
||||
graphics::MessageRenderer::nudgeScroll(1);
|
||||
handledEncoderScroll = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (handledEncoderScroll) {
|
||||
setFastFramerate();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (event->inputEvent == INPUT_BROKER_LEFT || event->inputEvent == INPUT_BROKER_ALT_PRESS) {
|
||||
showFrame(FrameDirection::PREVIOUS);
|
||||
} else if (event->inputEvent == INPUT_BROKER_RIGHT || event->inputEvent == INPUT_BROKER_USER_PRESS) {
|
||||
|
||||
@@ -238,6 +238,48 @@ void resetScrollState()
|
||||
didReset = false;
|
||||
}
|
||||
|
||||
void nudgeScroll(int8_t direction)
|
||||
{
|
||||
if (direction == 0)
|
||||
return;
|
||||
|
||||
if (cachedHeights.empty()) {
|
||||
scrollY = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
OLEDDisplay *display = (screen != nullptr) ? screen->getDisplayDevice() : nullptr;
|
||||
const int displayHeight = display ? display->getHeight() : 64;
|
||||
const int navHeight = FONT_HEIGHT_SMALL;
|
||||
const int usableHeight = std::max(0, displayHeight - navHeight);
|
||||
|
||||
int totalHeight = 0;
|
||||
for (int h : cachedHeights)
|
||||
totalHeight += h;
|
||||
|
||||
if (totalHeight <= usableHeight) {
|
||||
scrollY = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
const int scrollStop = std::max(0, totalHeight - usableHeight + cachedHeights.back());
|
||||
const int step = std::max(FONT_HEIGHT_SMALL, usableHeight / 3);
|
||||
|
||||
float newScroll = scrollY + static_cast<float>(direction) * static_cast<float>(step);
|
||||
if (newScroll < 0.0f)
|
||||
newScroll = 0.0f;
|
||||
if (newScroll > scrollStop)
|
||||
newScroll = static_cast<float>(scrollStop);
|
||||
|
||||
if (newScroll != scrollY) {
|
||||
scrollY = newScroll;
|
||||
waitingToReset = false;
|
||||
scrollStarted = false;
|
||||
scrollStartDelay = millis();
|
||||
lastTime = millis();
|
||||
}
|
||||
}
|
||||
|
||||
// Fully free cached message data from heap
|
||||
void clearMessageCache()
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "OLEDDisplayUi.h"
|
||||
#include "graphics/emotes.h"
|
||||
#include "mesh/generated/meshtastic/mesh.pb.h" // for meshtastic_MeshPacket
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -50,6 +51,9 @@ std::vector<int> calculateLineHeights(const std::vector<std::string> &lines, con
|
||||
// Reset scroll state when new messages arrive
|
||||
void resetScrollState();
|
||||
|
||||
// Manual scroll control for encoder-style inputs
|
||||
void nudgeScroll(int8_t direction);
|
||||
|
||||
// Helper to auto-select the correct thread mode from a message
|
||||
void setThreadFor(const StoredMessage &sm, const meshtastic_MeshPacket &packet);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user