Skip to content

Instantly share code, notes, and snippets.

@simonprickett
Created June 6, 2021 16:47
Show Gist options
  • Save simonprickett/e193ed1000a96493d607f428e671556e to your computer and use it in GitHub Desktop.
Save simonprickett/e193ed1000a96493d607f428e671556e to your computer and use it in GitHub Desktop.
Pomodoro Timer: Update an in progress timer.
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