DeskControl/src/lib/screen/calibrate.cpp

69 lines
1.5 KiB
C++

#include "./calibrate.h"
#include "./home.h"
#include "include/metrics.h"
#include "lib/settings.h"
void CalibrateScreen::initHeights()
{
this->height[CalibrateStepCurrent] = Control.getCurrentHeight();
this->height[CalibrateStepMax] = Settings.Height.Maximum;
this->height[CalibrateStepMin] = Settings.Height.Minimum;
}
bool CalibrateScreen::nextPage()
{
this->step = (CalibrateStep)(this->step + 1);
if (this->step < __CalibrateStepCount)
return true;
Settings.Height.Offset = this->height[CalibrateStepCurrent] - Control.getCurrentMeasurement();
Settings.Height.Maximum = this->height[CalibrateStepMax];
Settings.Height.Minimum = this->height[CalibrateStepMin];
writeSettingsHeights();
this->screenManager->show<HomeScreen>();
return false;
}
bool CalibrateScreen::isValidHeight()
{
switch (this->step)
{
case CalibrateStepCurrent:
return this->height[CalibrateStepCurrent] >= Control.getCurrentMeasurement();
case CalibrateStepMin:
return this->height[CalibrateStepMin] <= this->height[CalibrateStepCurrent];
case CalibrateStepMax:
return
this->height[CalibrateStepMax] > this->height[CalibrateStepMin] &&
this->height[CalibrateStepMax] >= this->height[CalibrateStepCurrent];
default:
return true;
}
}
const char* CalibrateScreen::getTitle()
{
switch (this->step)
{
case CalibrateStepCurrent:
return "Calibrate";
case CalibrateStepMin:
return "Minimum";
case CalibrateStepMax:
return "Maximum";
default:
return nullptr;
}
}