All change value displays now have a confirm and errorOccured

This commit is contained in:
2021-12-29 22:26:44 +01:00
parent 4b9a36f507
commit da1927776e
23 changed files with 269 additions and 263 deletions

View File

@@ -0,0 +1,50 @@
#include "changevaluedisplay_controltype.h"
// esp-idf includes
#include <esp_log.h>
// 3rdparty lib includes
#include <actions/setvalueaction.h>
#include <actions/backproxyaction.h>
#include <icons/back.h>
#include <futurecpp.h>
// local includes
#include "utils.h"
namespace espgui {
namespace {
constexpr const char * const TAG = "ESPGUI";
constexpr char TEXT_COMMUTATION[] = "Commutation";
constexpr char TEXT_SINUSOIDAL[] = "Sinusoidal";
constexpr char TEXT_FIELDORIENTEDCONTROL[] = "Field oriented control";
constexpr char TEXT_BACK[] = "Back";
} // namespace
ChangeValueDisplay<bobbycar::protocol::ControlType>::ChangeValueDisplay()
{
using bobbycar::protocol::ControlType;
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<ControlType>, StaticText<TEXT_COMMUTATION>>>(ControlType::Commutation, *this, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<ControlType>, StaticText<TEXT_SINUSOIDAL>>>(ControlType::Sinusoidal, *this, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<ControlType>, StaticText<TEXT_FIELDORIENTEDCONTROL>>>(ControlType::FieldOrientedControl, *this, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, BackProxyAction, StaticText<TEXT_BACK>, StaticMenuItemIcon<&espgui::icons::back>>>(*this);
}
void ChangeValueDisplay<bobbycar::protocol::ControlType>::start()
{
Base::start();
switch (const auto value = getValue())
{
using bobbycar::protocol::ControlType;
case ControlType::Commutation: setSelectedIndex(0); break;
case ControlType::Sinusoidal: setSelectedIndex(1); break;
case ControlType::FieldOrientedControl: setSelectedIndex(2); break;
default:
ESP_LOGW(TAG, "Unknown ControlType: %i", std::to_underlying(value));
setSelectedIndex(3);
}
}
} // namespace espgui