Implemented security measures
This commit is contained in:
@@ -174,21 +174,26 @@ void CalibrateDisplay::redraw()
|
|||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}());
|
}());
|
||||||
|
|
||||||
m_labels[9].redraw([&](){
|
{
|
||||||
switch (m_status)
|
const auto color = m_status == Status::Confirm && (m_gas > 100 || m_brems > 100) ? TFT_DARKGREY : TFT_WHITE;
|
||||||
{
|
tft.setTextColor(color, TFT_BLACK);
|
||||||
case Status::Begin: return "Yes";
|
m_labels[9].redraw([&](){
|
||||||
case Status::GasMin:
|
switch (m_status)
|
||||||
case Status::GasMax:
|
{
|
||||||
case Status::BremsMin:
|
case Status::Begin: return "Yes";
|
||||||
case Status::BremsMax: return "Next";
|
case Status::GasMin:
|
||||||
case Status::Confirm: return "Save";
|
case Status::GasMax:
|
||||||
}
|
case Status::BremsMin:
|
||||||
__builtin_unreachable();
|
case Status::BremsMax: return "Next";
|
||||||
}());
|
case Status::Confirm: return "Save";
|
||||||
|
}
|
||||||
|
__builtin_unreachable();
|
||||||
|
}());
|
||||||
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
|
||||||
if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0))
|
if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0))
|
||||||
tft.drawRect(23, 275, 100, 27, m_selectedButton == 0 ? TFT_WHITE : TFT_BLACK);
|
tft.drawRect(23, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
m_labels[10].redraw([&](){
|
m_labels[10].redraw([&](){
|
||||||
switch (m_status)
|
switch (m_status)
|
||||||
@@ -230,7 +235,9 @@ void CalibrateDisplay::back()
|
|||||||
switch (m_status)
|
switch (m_status)
|
||||||
{
|
{
|
||||||
case Status::Begin:
|
case Status::Begin:
|
||||||
if (!m_bootup)
|
if (m_bootup)
|
||||||
|
switchScreen<StatusDisplay>();
|
||||||
|
else
|
||||||
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
||||||
break;
|
break;
|
||||||
case Status::GasMin:
|
case Status::GasMin:
|
||||||
@@ -261,6 +268,11 @@ void CalibrateDisplay::confirm()
|
|||||||
case Status::GasMax:
|
case Status::GasMax:
|
||||||
m_gasMax = raw_gas;
|
m_gasMax = raw_gas;
|
||||||
m_status = Status::BremsMin;
|
m_status = Status::BremsMin;
|
||||||
|
{
|
||||||
|
const auto dead = (m_gasMax - m_gasMin)/20;
|
||||||
|
m_gasMin += dead;
|
||||||
|
m_gasMax -= dead;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Status::BremsMin:
|
case Status::BremsMin:
|
||||||
m_bremsMin = raw_brems;
|
m_bremsMin = raw_brems;
|
||||||
@@ -269,8 +281,15 @@ void CalibrateDisplay::confirm()
|
|||||||
case Status::BremsMax:
|
case Status::BremsMax:
|
||||||
m_bremsMax = raw_brems;
|
m_bremsMax = raw_brems;
|
||||||
m_status = Status::Confirm;
|
m_status = Status::Confirm;
|
||||||
|
{
|
||||||
|
const auto dead = (m_bremsMax - m_bremsMin)/20;
|
||||||
|
m_bremsMin += dead;
|
||||||
|
m_bremsMax -= dead;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Status::Confirm:
|
case Status::Confirm:
|
||||||
|
if (m_gas > 100 || m_brems > 100)
|
||||||
|
return;
|
||||||
copyToSettings();
|
copyToSettings();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
if (m_bootup)
|
if (m_bootup)
|
||||||
@@ -280,15 +299,7 @@ void CalibrateDisplay::confirm()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: // right button pressed
|
case 1: // right button pressed
|
||||||
if (m_status == Status::Begin)
|
back();
|
||||||
{
|
|
||||||
if (m_bootup)
|
|
||||||
switchScreen<StatusDisplay>();
|
|
||||||
else
|
|
||||||
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
back();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user