UVControl/src/ScreenCountdown.cpp

71 lines
1.2 KiB
C++

#include "ScreenCountdown.h"
#include "ScreenSetTime.h"
#include "ExposureTimer.h"
#include "Config.h"
#include "Buzzer.h"
void ScreenCountdown::printRemainingTime()
{
getDisplay()->setCursor(0, 1);
printTime(ExposureTime - ((getCurrentTime() - ExposureTimerStart) / 1000));
}
void ScreenCountdown::onShow()
{
mLastDisplayed = -1;
getDisplay()->setCursor(0, 0);
getDisplay()->print("Exposing... ");
printRemainingTime();
digitalWrite(PinLED, HIGH);
}
void ScreenCountdown::onHide()
{
digitalWrite(PinLED, LOW);
}
void ScreenCountdown::onButton()
{
// TODO Confirmation?
buzzClick();
getScreenManager()->show<ScreenSetTime>();
}
void ScreenCountdown::onEncoder(long lastPosition, long newPosition)
{
// TODO Allow adding / removing time?
}
void ScreenCountdown::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<ScreenSetTime>();
}
else if (elapsed != mLastDisplayed)
{
printRemainingTime();
mLastDisplayed = elapsed;
}
}