Skip to content

Commit

Permalink
Handle impossibly unlikely millis() overflow error
Browse files Browse the repository at this point in the history
Should have just let it go, but here we are..
  • Loading branch information
todd-herbert committed Mar 28, 2024
1 parent ffc1658 commit 8c5afa0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,9 +1363,12 @@ void Screen::setScreensaverFrames(FrameCallback einkScreensaver)

// Request new frame, ASAP
setFastFramerate();
uint64_t now = millis();
while (ui->getUiState()->lastUpdate < now)
uint64_t startUpdate;
do {
startUpdate = millis(); // Handle impossibly unlikely corner case of a millis() overflow..
delay(1);
ui->update();
} while (ui->getUiState()->lastUpdate < startUpdate);

#ifndef USE_EINK_DYNAMICDISPLAY
// Retrofit to EInkDisplay class
Expand Down

0 comments on commit 8c5afa0

Please sign in to comment.