Add scrolling to Node list

This commit is contained in:
HarukiToreda
2025-12-11 20:28:43 -05:00
parent 71bc99938c
commit cfea55d77d
3 changed files with 56 additions and 0 deletions

View File

@@ -1659,6 +1659,26 @@ int Screen::handleInputEvent(const InputEvent *event)
}
}
}
// UP/DOWN in node list screens scrolls through node pages
if (ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_nodes ||
ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_location ||
ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_lastheard ||
ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_hopsignal ||
ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_distance ||
ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_bearings)
{
if (event->inputEvent == INPUT_BROKER_UP) {
graphics::NodeListRenderer::scrollUp();
setFastFramerate();
return 0;
}
if (event->inputEvent == INPUT_BROKER_DOWN) {
graphics::NodeListRenderer::scrollDown();
setFastFramerate();
return 0;
}
}
// Use left or right input from a keyboard to move between frames,
// so long as a mesh module isn't using these events for some other purpose
if (showingNormalScreen) {

View File

@@ -50,6 +50,38 @@ static ListMode_Node currentMode_Nodes = MODE_LAST_HEARD;
static ListMode_Location currentMode_Location = MODE_DISTANCE;
static int scrollIndex = 0;
// =============================
// Scrolling Logic
// =============================
void scrollUp()
{
if (scrollIndex > 0)
scrollIndex--;
}
void scrollDown()
{
int totalEntries = nodeDB->getNumMeshNodes();
const int COMMON_HEADER_HEIGHT = FONT_HEIGHT_SMALL - 1;
const int rowYOffset = FONT_HEIGHT_SMALL - 3;
int screenHeight = screen->getHeight();
int visibleRows = (screenHeight - COMMON_HEADER_HEIGHT) / rowYOffset;
int totalColumns = 2;
#if defined(T_LORA_PAGER)
totalColumns = 3;
#endif
if (config.display.use_long_node_name)
totalColumns = 1;
int maxScroll = std::max(0, (totalEntries - 1) / (visibleRows * totalColumns));
if (scrollIndex < maxScroll)
scrollIndex++;
}
// =============================
// Utility Functions
// =============================

View File

@@ -59,6 +59,10 @@ const char *getCurrentModeTitle_Location(int screenWidth);
const char *getSafeNodeName(meshtastic_NodeInfoLite *node, int columnWidth);
void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields);
// Scrolling controls
void scrollUp();
void scrollDown();
// Bitmap drawing function
void drawScaledXBitmap16x16(int x, int y, int width, int height, const uint8_t *bitmapXBM, OLEDDisplay *display);