90 lines
2.6 KiB
C++
90 lines
2.6 KiB
C++
#include "./move.h"
|
|
#include "./home.h"
|
|
#include "include/config.h"
|
|
#include "include/metrics.h"
|
|
#include "lib/settings.h"
|
|
#include "lib/control.h"
|
|
|
|
|
|
|
|
void MoveScreen::onShow()
|
|
{
|
|
auto display = this->getDisplay();
|
|
auto startY = Metrics::LargeTextLineHeight;
|
|
auto arrowY = startY + Metrics::LargeTextLineHeight + Metrics::LargeTextLineVArrowYOffset;
|
|
auto arrowX = (Config::DisplayWidth - Metrics::VArrowWidth) / 2;
|
|
auto stopY = Config::DisplayHeight - Metrics::LargeTextLineHeight;
|
|
|
|
display->fillScreen(Config::ColorMoveBackground);
|
|
|
|
// Stop
|
|
display->setFont(Metrics::SmallFont);
|
|
display->setTextColor(Config::ColorMoveStop);
|
|
this->printCentered("Press any button to", stopY - Metrics::SmallTextLineHeight);
|
|
|
|
display->setFont(Metrics::LargeFont);
|
|
this->printCentered("STOP", stopY + Metrics::LargeTextLineYOffset);
|
|
|
|
char targetHeightText[6];
|
|
getDisplayHeight(&targetHeightText[0], State.MoveTarget);
|
|
display->setTextColor(Config::ColorMoveCurrent);
|
|
|
|
// Target and arrow
|
|
if (State.MoveDirection == Direction::Up)
|
|
{
|
|
this->currentHeightY = startY + (Metrics::LargeTextLineHeight * 2);
|
|
|
|
this->printCentered(&targetHeightText[0], startY + Metrics::LargeTextLineYOffset);
|
|
this->drawArrowUp(arrowX, arrowY, Config::ColorMoveArrow);
|
|
}
|
|
else
|
|
{
|
|
this->currentHeightY = startY;
|
|
|
|
this->printCentered(&targetHeightText[0], startY + (Metrics::LargeTextLineHeight * 2) + Metrics::LargeTextLineYOffset);
|
|
this->drawArrowDown(arrowX, arrowY, Config::ColorMoveArrow);
|
|
}
|
|
|
|
this->lastRefresh = State.CurrentTime;
|
|
this->drawCurrentHeight();
|
|
}
|
|
|
|
|
|
void MoveScreen::onButton(Button button)
|
|
{
|
|
controlStop();
|
|
this->getScreenManager()->show<HomeScreen>();
|
|
}
|
|
|
|
|
|
void MoveScreen::onTick()
|
|
{
|
|
if (State.MoveDirection == Direction::None)
|
|
{
|
|
this->getScreenManager()->show<HomeScreen>();
|
|
return;
|
|
}
|
|
|
|
// Don't update every tick, monitoring the current height is more
|
|
// important and the flicker would be unpleasant as well.
|
|
if (State.CurrentTime - this->lastRefresh >= Config::DisplayMoveRefreshRate)
|
|
{
|
|
this->drawCurrentHeight();
|
|
this->lastRefresh = State.CurrentTime;
|
|
}
|
|
}
|
|
|
|
|
|
void MoveScreen::drawCurrentHeight()
|
|
{
|
|
auto display = this->getDisplay();
|
|
|
|
char currentHeightText[6];
|
|
getDisplayHeight(¤tHeightText[0], State.CurrentHeight);
|
|
|
|
if (this->lastTextWidth > 0)
|
|
display->fillRect((Config::DisplayWidth - this->lastTextWidth) / 2, this->currentHeightY, this->lastTextWidth, Metrics::LargeTextLineHeight, Config::ColorMoveBackground);
|
|
|
|
display->setTextColor(Config::ColorMoveTarget);
|
|
this->lastTextWidth = this->printCentered(¤tHeightText[0], this->currentHeightY + Metrics::LargeFontBaseline);
|
|
} |