Created
June 6, 2021 16:47
-
-
Save simonprickett/e193ed1000a96493d607f428e671556e to your computer and use it in GitHub Desktop.
Pomodoro Timer: Update an in progress timer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (currentState != STATE_IDLE) { | |
unsigned long timeNow = millis(); | |
if (timeNow - startTime >= MILLIS_IN_ONE_MIN) { | |
minsRemaining--; | |
if (minsRemaining == 0) { | |
playTone(3); | |
// Work out what state comes next... | |
if (currentState == STATE_WORKING) { | |
currIteration++; | |
if (currIteration == 5) { | |
currIteration = 1; | |
minsRemaining = LONG_BREAK_MINS; | |
currentState = STATE_BREAK; | |
sprintf(statusBuf, "Long break..."); | |
} else { | |
minsRemaining = SHORT_BREAK_MINS; | |
currentState = STATE_BREAK; | |
sprintf(statusBuf, "Short break..."); | |
} | |
} else if (currentState == STATE_BREAK) { | |
minsRemaining = POMODORO_MINS; | |
currentState = STATE_WORKING; | |
sprintf(statusBuf, "Time to work... %d/4", currIteration); | |
} | |
} | |
drawScreen(statusBuf, minsRemaining); | |
startTime = millis(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment