Skip to content
19 changes: 14 additions & 5 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,9 +2054,11 @@ void Screen::setScreensaverFrames(FrameCallback einkScreensaver)
#endif

// restore our regular frame list
void Screen::setFrames()
void Screen::setFrames(bool holdPosition = false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget the one declaration in Screen.h either!
(because of the order of Screen.cpp, I also think you'll want to set that =false default argument in Screen.h instead)

{
LOG_DEBUG("showing standard frames\n");
uint8_t currentFrameNum = ui->getUiState()->currentFrame;
LOG_DEBUG("Showing standard frame number %d\n", currentFrameNum);

showingNormalScreen = true;

#ifdef USE_EINK
Expand Down Expand Up @@ -2147,7 +2149,14 @@ void Screen::setFrames()
// just changed)

setFastFramerate(); // Draw ASAP
}

if (holdPosition) {
ui->switchToFrame(currentFrameNum); // Attempt to return to same frame after rebuilding the frames,
// if holdPosition is true (currently only Screen::handleStatusUpdate calls this
} else {
continue; // We leave the displayed frame as it is or chnage focuse to new frame

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did have a bit of a play with this a few days ago, and I think there might be a sneaky issue here: if you're trying to stay on the "log buffer" frame, and the number of frames increases, switchToFrame(currentFrameNum) won't put you back in the same place.

}
}

void Screen::handleStartBluetoothPinScreen(uint32_t pin)
{
Expand Down Expand Up @@ -2646,7 +2655,7 @@ int Screen::handleStatusUpdate(const meshtastic::Status *arg)
switch (arg->getStatusType()) {
case STATUS_TYPE_NODE:
if (showingNormalScreen && nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) {
setFrames(); // Regen the list of screens
setFrames(true); // Regen the list of screens, will show the previously displayed frame
}
nodeDB->updateGUI = false;
break;
Expand Down Expand Up @@ -2712,4 +2721,4 @@ int Screen::handleInputEvent(const InputEvent *event)
} // namespace graphics
#else
graphics::Screen::Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY) {}
#endif // HAS_SCREEN
#endif // HAS_SCREEN