Skip to content

Commit

Permalink
Handle millis() overflow
Browse files Browse the repository at this point in the history
Avoid getting stuck in a while loop
  • Loading branch information
todd-herbert authored Mar 28, 2024
1 parent ffc1658 commit f5fdbe0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,8 +1364,10 @@ void Screen::setScreensaverFrames(FrameCallback einkScreensaver)
// Request new frame, ASAP
setFastFramerate();
uint64_t now = millis();
while (ui->getUiState()->lastUpdate < now)
while (ui->getUiState()->lastUpdate < now) {
ui->update();
now = millis(); // Handle millis() overflow
}

#ifndef USE_EINK_DYNAMICDISPLAY
// Retrofit to EInkDisplay class
Expand Down Expand Up @@ -1960,4 +1962,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

0 comments on commit f5fdbe0

Please sign in to comment.