UVControl/src/ScreenCountdown.cpp

71 lines
1.2 KiB
C++
Raw Normal View History

2017-11-26 19:22:15 +00:00
#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()
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 ScreenCountdown::onHide()
{
digitalWrite(PinLED, LOW);
}
void ScreenCountdown::onButton()
{
// TODO Confirmation?
buzzClick();
getScreenManager()->show<ScreenSetTime>();
}
void ScreenCountdown::onEncoder(long lastPosition, long newPosition)
{
2017-11-27 14:51:32 +00:00
// TODO Allow adding / removing time?
2017-11-26 19:22:15 +00:00
}
void ScreenCountdown::onTick()
{
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<ScreenSetTime>();
}
else if (elapsed != mLastDisplayed)
{
printRemainingTime();
mLastDisplayed = elapsed;
}
}