UVControl/src/Screen/CountdownScreen.cpp

74 lines
1.3 KiB
C++
Raw Normal View History

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