2020-01-31 09:36:36 +00:00
|
|
|
#include "./move-sensorerror.h"
|
2020-02-01 15:55:33 +00:00
|
|
|
#include "./home.h"
|
2020-01-31 15:50:19 +00:00
|
|
|
#include "include/config.h"
|
|
|
|
#include "include/metrics.h"
|
|
|
|
#include "lib/control.h"
|
|
|
|
#include "lib/state.h"
|
2020-01-31 09:36:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MoveSensorErrorScreen::onShow()
|
|
|
|
{
|
2020-01-31 15:50:19 +00:00
|
|
|
auto y = Metrics::LargeTextLineHeight + Metrics::LargeTextLineYOffset;
|
2020-01-31 09:36:36 +00:00
|
|
|
|
2020-02-01 15:55:33 +00:00
|
|
|
this->display->fillScreen(Config::ColorErrorBackground);
|
|
|
|
|
|
|
|
|
|
|
|
this->display->setFont(Metrics::LargeFont);
|
|
|
|
this->display->setTextSize(Metrics::LargeFontTextSize);
|
|
|
|
|
|
|
|
this->display->setTextColor(Config::ColorErrorText);
|
2020-01-31 15:50:19 +00:00
|
|
|
this->printCentered("ERROR", y);
|
|
|
|
y += Metrics::LargeTextLineHeight;
|
|
|
|
|
2020-02-01 15:55:33 +00:00
|
|
|
this->display->setFont(Metrics::SmallFont);
|
|
|
|
this->display->setTextSize(Metrics::SmallFontTextSize);
|
|
|
|
|
2020-01-31 15:50:19 +00:00
|
|
|
this->printCentered("height sensor failed", y);
|
|
|
|
y += Metrics::SmallTextLineHeight;
|
|
|
|
|
|
|
|
this->printCentered("waiting for stable value", y);
|
|
|
|
y += Metrics::SmallTextLineHeight + Metrics::LargeTextLineHeight;
|
|
|
|
|
|
|
|
this->currentHeightY = y;
|
|
|
|
|
2020-02-01 15:55:33 +00:00
|
|
|
|
|
|
|
this->display->setFont(Metrics::LargeFont);
|
|
|
|
this->display->setTextSize(Metrics::LargeFontTextSize);
|
|
|
|
|
2020-01-31 15:50:19 +00:00
|
|
|
this->lastRefresh = CurrentTime;
|
2020-02-01 15:55:33 +00:00
|
|
|
this->drawLastMeasurement();
|
|
|
|
|
|
|
|
Control.stabilizeStart();
|
2020-01-31 09:36:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MoveSensorErrorScreen::onButton(Button button)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MoveSensorErrorScreen::onTick()
|
|
|
|
{
|
2020-02-01 15:55:33 +00:00
|
|
|
if (Control.stabilized())
|
|
|
|
{
|
|
|
|
this->screenManager->show<HomeScreen>();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CurrentTime - this->lastRefresh >= Config::DisplayRefreshRate)
|
|
|
|
{
|
|
|
|
this->drawLastMeasurement();
|
|
|
|
this->lastRefresh = CurrentTime;
|
|
|
|
}
|
2020-01-31 15:50:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-01 15:55:33 +00:00
|
|
|
void MoveSensorErrorScreen::drawLastMeasurement()
|
2020-01-31 15:50:19 +00:00
|
|
|
{
|
|
|
|
char currentHeightText[6];
|
2020-02-01 15:55:33 +00:00
|
|
|
Control.getDisplayHeight(¤tHeightText[0], Control.getLastMeasurement());
|
2020-01-31 15:50:19 +00:00
|
|
|
|
|
|
|
if (this->lastTextWidth > 0)
|
2020-02-01 15:55:33 +00:00
|
|
|
this->display->fillRect((Config::DisplayWidth - this->lastTextWidth) / 2, this->currentHeightY, this->lastTextWidth, Metrics::LargeTextLineHeight, Config::ColorErrorBackground);
|
2020-01-31 15:50:19 +00:00
|
|
|
|
2020-02-01 15:55:33 +00:00
|
|
|
this->display->setTextColor(Config::ColorMoveTarget);
|
2020-01-31 15:50:19 +00:00
|
|
|
this->lastTextWidth = this->printCentered(¤tHeightText[0], this->currentHeightY + Metrics::LargeFontBaseline);
|
2020-01-31 09:36:36 +00:00
|
|
|
}
|