#include "CountdownScreen.h" #include "Screen/SetTimeScreen.h" #include "ExposureTimer.h" #include "Config.h" #include "Buzzer.h" void CountdownScreen::printRemainingTime() { getDisplay()->setCursor(0, 1); String time = FormatTime(ExposureTime - ((getCurrentTime() - ExposureTimerStart) / 1000)); // TODO blank out, center, etc getDisplay()->print(time); } void CountdownScreen::onShow() { mLastDisplayed = -1; getDisplay()->setCursor(0, 0); getDisplay()->print("Exposing... "); printRemainingTime(); digitalWrite(PinLED, HIGH); } void CountdownScreen::onHide() { digitalWrite(PinLED, LOW); } void CountdownScreen::onButton() { // TODO Confirmation? buzzClick(); getScreenManager()->show(); } void CountdownScreen::onEncoder(long lastPosition, long newPosition) { // TODO Allow adding / removing time? } void CountdownScreen::onTick() { long elapsed = (getCurrentTime() - ExposureTimerStart) / 1000; if (elapsed >= ExposureTime) { getDisplay()->setCursor(0, 0); getDisplay()->print("Done! "); printRemainingTime(); digitalWrite(PinLED, LOW); buzzCompleted(); ExposureTimerStart = 0; getScreenManager()->show(); } else if (elapsed != mLastDisplayed) { printRemainingTime(); mLastDisplayed = elapsed; } }