#include "changevaluedisplay_controlmode.h" // system includes #include // esp-idf includes #include // 3rdparty lib includes #include #include #include // local includes #include "utils.h" namespace espgui { namespace { constexpr const char * const TAG = "ESPGUI"; constexpr char TEXT_OPENMODE[] = "Open mode"; constexpr char TEXT_VOLTAGE[] = "Voltage"; constexpr char TEXT_SPEED[] = "Speed"; constexpr char TEXT_TORQUE[] = "Torque"; constexpr char TEXT_BACK[] = "Back"; } // namespace ChangeValueDisplay::ChangeValueDisplay() { using bobbycar::protocol::ControlMode; constructMenuItem, StaticText>>(ControlMode::OpenMode, *this, *this, *this); constructMenuItem, StaticText>>(ControlMode::Voltage, *this, *this, *this); constructMenuItem, StaticText>>(ControlMode::Speed, *this, *this, *this); constructMenuItem, StaticText>>(ControlMode::Torque, *this, *this, *this); constructMenuItem, StaticMenuItemIcon<&espgui::icons::back>>>(*this); } void ChangeValueDisplay::start() { Base::start(); switch (const auto value = getValue()) { using bobbycar::protocol::ControlMode; case ControlMode::OpenMode: setSelectedIndex(0); break; case ControlMode::Voltage: setSelectedIndex(1); break; case ControlMode::Speed: setSelectedIndex(2); break; case ControlMode::Torque: setSelectedIndex(3); break; default: ESP_LOGW(TAG, "Unknown ControlMode: %i", std::to_underlying(value)); setSelectedIndex(4); } } } // namespace espgui