70 lines
1.2 KiB
C++
70 lines
1.2 KiB
C++
#include "countdown.h"
|
|
#include "screen/menu.h"
|
|
#include "display.h"
|
|
#include "state.h"
|
|
#include "config.h"
|
|
#include "buzzer.h"
|
|
|
|
|
|
void CountdownScreen::printRemainingTime()
|
|
{
|
|
LCDPrintLineCentered(getDisplay(), 1, FormatTime(mLastDisplayed));
|
|
}
|
|
|
|
|
|
void CountdownScreen::onShow()
|
|
{
|
|
LCDPrintLine(getDisplay(), 0, "Exposing...");
|
|
|
|
mLastDisplayed = GetExposureTimeRemaining(getCurrentTime()) / 1000;
|
|
printRemainingTime();
|
|
|
|
digitalWrite(PinLED, HIGH);
|
|
}
|
|
|
|
|
|
void CountdownScreen::onHide()
|
|
{
|
|
digitalWrite(PinLED, LOW);
|
|
}
|
|
|
|
|
|
void CountdownScreen::onButton()
|
|
{
|
|
// TODO Confirmation?
|
|
Buzzer::click();
|
|
getScreenManager()->show<MenuScreen>();
|
|
}
|
|
|
|
|
|
void CountdownScreen::onEncoder(long lastPosition, long newPosition)
|
|
{
|
|
// TODO Allow adding / removing time?
|
|
}
|
|
|
|
|
|
void CountdownScreen::onTick()
|
|
{
|
|
uint32_t remaining = GetExposureTimeRemaining(getCurrentTime()) / 1000;
|
|
|
|
if (remaining == 0)
|
|
{
|
|
mLastDisplayed = 0;
|
|
|
|
LCDPrintLine(getDisplay(), 0, "Done!");
|
|
printRemainingTime();
|
|
digitalWrite(PinLED, LOW);
|
|
|
|
Buzzer::completed();
|
|
|
|
ResetExposureTimer();
|
|
getScreenManager()->show<MenuScreen>();
|
|
}
|
|
else if (remaining != mLastDisplayed)
|
|
{
|
|
mLastDisplayed = remaining;
|
|
printRemainingTime();
|
|
}
|
|
}
|
|
|