diff --git a/components/esp-gui-lib b/components/esp-gui-lib index 8c450b8..65a8c98 160000 --- a/components/esp-gui-lib +++ b/components/esp-gui-lib @@ -1 +1 @@ -Subproject commit 8c450b8116d2aa1c982843a0b6144f626b721301 +Subproject commit 65a8c98530c37d209bd7e40c9d509b9e7407edeb diff --git a/config_allfeatures.cmake b/config_allfeatures.cmake index 2526881..d7c500e 100644 --- a/config_allfeatures.cmake +++ b/config_allfeatures.cmake @@ -57,26 +57,7 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_DPAD_6WIRESW_IN4=19 -DPINS_DPAD_6WIRESW_IN5=26 -# -DDPAD_5WIRESW_UP=1 -# -DDPAD_5WIRESW_DOWN=5 -# -DDPAD_5WIRESW_CONFIRM=2 -# -DDPAD_5WIRESW_BACK=6 -# -DDPAD_5WIRESW_PROFILE0=4 -# -DDPAD_5WIRESW_PROFILE1=0 -# -DDPAD_5WIRESW_PROFILE2=7 -# -DDPAD_5WIRESW_PROFILE3=3 # -DDPAD_5WIRESW_DEBUG - - -DDPAD_6WIRESW_UP=1 - -DDPAD_6WIRESW_DOWN=5 - -DDPAD_6WIRESW_CONFIRM=2 - -DDPAD_6WIRESW_BACK=6 - -DDPAD_6WIRESW_PROFILE0=4 - -DDPAD_6WIRESW_PROFILE1=0 - -DDPAD_6WIRESW_PROFILE2=7 - -DDPAD_6WIRESW_PROFILE3=3 - -DDPAD_6WIRESW_BLINK_LEFT=8 - -DDPAD_6WIRESW_BLINK_RIGHT=9 # -DDPAD_6WIRESW_DEBUG -DFEATURE_GSCHISSENE_DIODE diff --git a/config_comred.cmake b/config_comred.cmake index dbc51d7..96025d0 100644 --- a/config_comred.cmake +++ b/config_comred.cmake @@ -57,26 +57,7 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_DPAD_6WIRESW_IN4=19 -DPINS_DPAD_6WIRESW_IN5=26 -# -DDPAD_5WIRESW_UP=1 -# -DDPAD_5WIRESW_DOWN=5 -# -DDPAD_5WIRESW_CONFIRM=2 -# -DDPAD_5WIRESW_BACK=6 -# -DDPAD_5WIRESW_PROFILE0=4 -# -DDPAD_5WIRESW_PROFILE1=0 -# -DDPAD_5WIRESW_PROFILE2=7 -# -DDPAD_5WIRESW_PROFILE3=3 # -DDPAD_5WIRESW_DEBUG - - -DDPAD_6WIRESW_UP=1 - -DDPAD_6WIRESW_DOWN=5 - -DDPAD_6WIRESW_CONFIRM=2 - -DDPAD_6WIRESW_BACK=6 - -DDPAD_6WIRESW_PROFILE0=4 - -DDPAD_6WIRESW_PROFILE1=0 - -DDPAD_6WIRESW_PROFILE2=7 - -DDPAD_6WIRESW_PROFILE3=3 - -DDPAD_6WIRESW_BLINK_LEFT=8 - -DDPAD_6WIRESW_BLINK_RIGHT=9 # -DDPAD_6WIRESW_DEBUG -DFEATURE_GSCHISSENE_DIODE diff --git a/config_feedc0de.cmake b/config_feedc0de.cmake index 5372cac..a1bb05c 100644 --- a/config_feedc0de.cmake +++ b/config_feedc0de.cmake @@ -48,18 +48,6 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_DPAD_5WIRESW_IN1=27 -DPINS_DPAD_5WIRESW_IN2=32 -DPINS_DPAD_5WIRESW_IN3=33 - -DDPAD_5WIRESW_UP=2 - -DDPAD_5WIRESW_DOWN=11 - -DDPAD_5WIRESW_CONFIRM=5 - -DDPAD_5WIRESW_BACK=8 - -DDPAD_5WIRESW_PROFILE0=4 - -DDPAD_5WIRESW_PROFILE1=1 - -DDPAD_5WIRESW_PROFILE2=10 - -DDPAD_5WIRESW_PROFILE3=7 - -DDPAD_5WIRESW_BLINK_LEFT=9 - -DDPAD_5WIRESW_BLINK_RIGHT=0 - -DDPAD_5WIRESW_QUICKACTION_DOWN=3 - -DDPAD_5WIRESW_QUICKACTION_UP=6 # -DDPAD_5WIRESW_DEBUG -DFEATURE_BLE # -DFEATURE_BLUETOOTH diff --git a/config_greyhash.cmake b/config_greyhash.cmake index 76582e3..408b5cf 100644 --- a/config_greyhash.cmake +++ b/config_greyhash.cmake @@ -48,14 +48,6 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_DPAD_5WIRESW_IN2=27 -DPINS_DPAD_5WIRESW_IN3=18 -DPINS_DPAD_5WIRESW_IN4=19 - -DDPAD_5WIRESW_UP=1 - -DDPAD_5WIRESW_DOWN=5 - -DDPAD_5WIRESW_CONFIRM=2 - -DDPAD_5WIRESW_BACK=6 - -DDPAD_5WIRESW_PROFILE0=4 - -DDPAD_5WIRESW_PROFILE1=0 - -DDPAD_5WIRESW_PROFILE2=7 - -DDPAD_5WIRESW_PROFILE3=3 # -DDPAD_5WIRESW_DEBUG # -DFEATURE_BLE # -DFEATURE_BLUETOOTH diff --git a/config_mick.cmake b/config_mick.cmake index 1380aff..f0651e0 100644 --- a/config_mick.cmake +++ b/config_mick.cmake @@ -48,14 +48,6 @@ set(BOBBYCAR_BUILDFLAGS # -DPINS_DPAD_5WIRESW_IN2=27 # -DPINS_DPAD_5WIRESW_IN3=18 # -DPINS_DPAD_5WIRESW_IN4=19 -# -DDPAD_5WIRESW_UP=1 -# -DDPAD_5WIRESW_DOWN=5 -# -DDPAD_5WIRESW_CONFIRM=2 -# -DDPAD_5WIRESW_BACK=6 -# -DDPAD_5WIRESW_PROFILE0=4 -# -DDPAD_5WIRESW_PROFILE1=0 -# -DDPAD_5WIRESW_PROFILE2=7 -# -DDPAD_5WIRESW_PROFILE3=3 # -DDPAD_5WIRESW_DEBUG -DFEATURE_BLE # -DFEATURE_BLUETOOTH diff --git a/config_nofeatures.cmake b/config_nofeatures.cmake index e9a61cd..9bbee40 100644 --- a/config_nofeatures.cmake +++ b/config_nofeatures.cmake @@ -57,26 +57,7 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_DPAD_6WIRESW_IN4=19 -DPINS_DPAD_6WIRESW_IN5=26 -# -DDPAD_5WIRESW_UP=1 -# -DDPAD_5WIRESW_DOWN=5 -# -DDPAD_5WIRESW_CONFIRM=2 -# -DDPAD_5WIRESW_BACK=6 -# -DDPAD_5WIRESW_PROFILE0=4 -# -DDPAD_5WIRESW_PROFILE1=0 -# -DDPAD_5WIRESW_PROFILE2=7 -# -DDPAD_5WIRESW_PROFILE3=3 # -DDPAD_5WIRESW_DEBUG - - -DDPAD_6WIRESW_UP=1 - -DDPAD_6WIRESW_DOWN=5 - -DDPAD_6WIRESW_CONFIRM=2 - -DDPAD_6WIRESW_BACK=6 - -DDPAD_6WIRESW_PROFILE0=4 - -DDPAD_6WIRESW_PROFILE1=0 - -DDPAD_6WIRESW_PROFILE2=7 - -DDPAD_6WIRESW_PROFILE3=3 - -DDPAD_6WIRESW_BLINK_LEFT=8 - -DDPAD_6WIRESW_BLINK_RIGHT=9 # -DDPAD_6WIRESW_DEBUG # -DFEATURE_GSCHISSENE_DIODE diff --git a/config_peter.cmake b/config_peter.cmake index 260d561..a4d73cc 100644 --- a/config_peter.cmake +++ b/config_peter.cmake @@ -48,18 +48,6 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_DPAD_5WIRESW_IN1=4 -DPINS_DPAD_5WIRESW_IN2=5 -DPINS_DPAD_5WIRESW_IN3=27 - -DDPAD_5WIRESW_UP=4 - -DDPAD_5WIRESW_DOWN=7 - -DDPAD_5WIRESW_CONFIRM=1 - -DDPAD_5WIRESW_BACK=10 - -DDPAD_5WIRESW_PROFILE0=11 - -DDPAD_5WIRESW_PROFILE1=8 - -DDPAD_5WIRESW_PROFILE2=5 - -DDPAD_5WIRESW_PROFILE3=2 - -DDPAD_5WIRESW_BLINK_LEFT=9 - -DDPAD_5WIRESW_BLINK_RIGHT=0 - -DDPAD_5WIRESW_QUICKACTION_DOWN=3 - -DDPAD_5WIRESW_QUICKACTION_UP=6 # -DDPAD_5WIRESW_DEBUG -DFEATURE_BLE # -DFEATURE_BLUETOOTH diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index caffdb1..cb4fa90 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -11,7 +11,6 @@ set(headers bobbycheckbox.h bobbyerrorhandler.h buildserver.h - buttons.h can.h changevaluedisplay_bluetoothmode.h changevaluedisplay_controlmode.h @@ -228,7 +227,6 @@ set(headers modes/tempomatmode.h texthelpers/networktexthelpers.h texthelpers/wifiaptexthelpers.h - texthelpers/wifistaconfigtexthelpers.h texthelpers/wifistatexthelpers.h widgets/doubleprogressbar.h ) @@ -244,7 +242,6 @@ set(sources bobbybuttons.cpp bobbyerrorhandler.cpp buildserver.cpp - buttons.cpp can.cpp changevaluedisplay_bluetoothmode.cpp changevaluedisplay_controlmode.cpp @@ -456,7 +453,6 @@ set(sources modes/tempomatmode.cpp texthelpers/networktexthelpers.cpp texthelpers/wifiaptexthelpers.cpp - texthelpers/wifistaconfigtexthelpers.cpp texthelpers/wifistatexthelpers.cpp widgets/doubleprogressbar.cpp ) diff --git a/main/actions/ledstripanimationactions.h b/main/actions/ledstripanimationactions.h index 9f705c5..3dd39ad 100644 --- a/main/actions/ledstripanimationactions.h +++ b/main/actions/ledstripanimationactions.h @@ -1,11 +1,14 @@ #pragma once +// 3rdparty lib includes #include "actioninterface.h" + +// local includes #include "ledstrip.h" -// #include "ledstripdefines.h" +#include "ledstripdefines.h" #ifdef FEATURE_LEDSTRIP -template +template class LedStripSetAnimationAction : public virtual espgui::ActionInterface { public: diff --git a/main/bobbybuttons.cpp b/main/bobbybuttons.cpp index 8a4b5cd..8b35a19 100644 --- a/main/bobbybuttons.cpp +++ b/main/bobbybuttons.cpp @@ -1,7 +1,20 @@ #include "bobbybuttons.h" +// esp-idf includes +#include + // local includes #include "newsettings.h" +#include "settingsutils.h" +#include "modes/defaultmode.h" +#ifdef FEATURE_LEDSTRIP +#include "ledstripdefines.h" +#include "ledstrip.h" +#endif + +namespace { +constexpr const char TAG[] = "BUTTONS"; +} // namespace [[nodiscard]] std::optional translateRawButton(uint8_t button) { @@ -35,6 +48,8 @@ if (configs.dpadMappingDown2.value == button) return Button(BobbyButton::Down2); + ESP_LOGW(TAG, "unknown raw button %hhu", button); + return std::nullopt; } @@ -42,14 +57,64 @@ void buttonPressedCommon(espgui::Button button) { switch (BobbyButton(button)) { - case BobbyButton::Profile0: /* TODO */ break; - case BobbyButton::Profile1: /* TODO */ break; - case BobbyButton::Profile2: /* TODO */ break; - case BobbyButton::Profile3: /* TODO */ break; - case BobbyButton::Left2: /* TODO */ break; - case BobbyButton::Right2: /* TODO */ break; - case BobbyButton::Up2: /* TODO */ break; - case BobbyButton::Down2: /* TODO */ break; + case BobbyButton::Profile0: + settingsutils::switchProfile(0); + break; + case BobbyButton::Profile1: + settingsutils::switchProfile(1); + break; + case BobbyButton::Profile2: + settingsutils::switchProfile(2); + break; + case BobbyButton::Profile3: + settingsutils::switchProfile(3); + break; + case BobbyButton::Left2: +#ifdef FEATURE_LEDSTRIP + if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to left + { + blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; + } + else if (blinkAnimation == LEDSTRIP_OVERWRITE_BLINKRIGHT) // transition to warning + { + blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; + } + else // transition to off + { + blinkAnimation = LEDSTRIP_OVERWRITE_NONE; + } +#endif + break; + case BobbyButton::Right2: +#ifdef FEATURE_LEDSTRIP + if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to right + { + blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; + } + else if (blinkAnimation == LEDSTRIP_OVERWRITE_BLINKLEFT) // transition to warning + { + blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; + } + else // transition to off + { + blinkAnimation = LEDSTRIP_OVERWRITE_NONE; + } +#endif + break; + case BobbyButton::Up2: + if (settings.handbremse.enable) + { + using namespace handbremse; + if (stateWish == StateWish::brake || angezogen) + stateWish = StateWish::release; + else + stateWish = StateWish::brake; + wishTimer = espchrono::millis_clock::now(); + } + break; + case BobbyButton::Down2: + /* TODO */ + break; default:; } } diff --git a/main/buttons.cpp b/main/buttons.cpp deleted file mode 100644 index 9abc31a..0000000 --- a/main/buttons.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include "buttons.h" -#include "modes/defaultmode.h" - -using namespace std::chrono_literals; - -int rotated{}; -bool requestFullRedraw{}; - -bool confirmButtonPressed{}; -bool confirmButtonLongPressed{}; -bool backButtonPressed{}; -bool backButtonLongPressed{}; - -bool profileButtonDisabled{}; - -std::optional upPressedSince; -int upPressRepeat{}; -std::optional downPressedSince; -int downPressRepeat{}; - -void InputDispatcher::init() -{ - -} - -void InputDispatcher::update() -{ - if (upPressedSince && espchrono::ago(*upPressedSince) > (upPressRepeat > 2 ? 50ms : 400ms)) - { - upPressedSince = espchrono::millis_clock::now(); - upPressRepeat++; - rotated -= 1; - } - - if (downPressedSince && espchrono::ago(*downPressedSince) > (downPressRepeat > 2 ? 50ms : 400ms)) - { - downPressedSince = espchrono::millis_clock::now(); - downPressRepeat++; - rotated += 1; - } -} - -void InputDispatcher::rotate(int offset) -{ - rotated += offset; -} - -void InputDispatcher::upButton(bool pressed) -{ - if (pressed) - { - upPressedSince = espchrono::millis_clock::now(); - upPressRepeat = 0; - rotated -= 1; - } - else - { - upPressedSince = std::nullopt; - } -} - -void InputDispatcher::downButton(bool pressed) -{ - if (pressed) - { - downPressedSince = espchrono::millis_clock::now(); - downPressRepeat = 0; - rotated += 1; - } - else - { - downPressedSince = std::nullopt; - } -} - -void InputDispatcher::confirmButton(bool pressed) -{ - static espchrono::millis_clock::time_point pressBegin{}; - - const auto now = espchrono::millis_clock::now(); - - if (pressed) - pressBegin = now; - else - { - const auto duration = now - pressBegin; - - if (duration < 500ms) - confirmButtonPressed = true; - else if (duration < 2000ms) - confirmButtonLongPressed = true; - else - requestFullRedraw = true; - - pressBegin = {}; - } -} - -void InputDispatcher::backButton(bool pressed) -{ - static espchrono::millis_clock::time_point pressBegin{}; - - const auto now = espchrono::millis_clock::now(); - - if (pressed) - pressBegin = now; - else - { - const auto duration = now - pressBegin; - - if (duration < 500ms) - backButtonPressed = true; - else - backButtonLongPressed = true; - - pressBegin = {}; - } -} - -void InputDispatcher::profileButton(uint8_t index, bool pressed) -{ - if (!pressed) - return; - - if (profileButtonDisabled) - return; - - settingsutils::switchProfile(index); -} - -#ifdef SWITCH_BLINK -void InputDispatcher::blinkRightButton(bool pressed) -#else -void InputDispatcher::blinkLeftButton(bool pressed) -#endif -{ - if(!pressed)return; - -#ifdef FEATURE_LEDSTRIP - if(blinkAnimation == LEDSTRIP_OVERWRITE_NONE){ //transition from off to left - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; - } - else if(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKRIGHT){ // transition to warning - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; - } - else{ // transition to off - blinkAnimation = LEDSTRIP_OVERWRITE_NONE; - } -#endif -} - -#ifndef SWITCH_BLINK -void InputDispatcher::blinkRightButton(bool pressed) -#else -void InputDispatcher::blinkLeftButton(bool pressed) -#endif -{ - if(!pressed)return; -#ifdef FEATURE_LEDSTRIP - if(blinkAnimation == LEDSTRIP_OVERWRITE_NONE){ //transition from off to right - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; - } - else if(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKLEFT){ // transition to warning - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; - } - else{ // transition to off - blinkAnimation = LEDSTRIP_OVERWRITE_NONE; - } -#endif -} - -void InputDispatcher::quickActionButtonDown(bool pressed) -{ - using namespace handbremse; - - if(!pressed)return; - - if (settings.handbremse.enable) - { - if (stateWish == StateWish::brake || angezogen) - stateWish = StateWish::release; - else - stateWish = StateWish::brake; - wishTimer = espchrono::millis_clock::now(); - } -} - -void InputDispatcher::quickActionButtonUp(bool pressed) -{ - -} diff --git a/main/buttons.h b/main/buttons.h deleted file mode 100644 index 90eb642..0000000 --- a/main/buttons.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -// system includes -#include - -// 3rdparty lib includes -#include - -// local includes -#include "settingsutils.h" -#include "ledstripdefines.h" - -#ifdef FEATURE_LEDSTRIP -#include "ledstrip.h" -#endif - -extern int rotated; -extern bool requestFullRedraw; - -extern bool confirmButtonPressed; -extern bool confirmButtonLongPressed; -extern bool backButtonPressed; -extern bool backButtonLongPressed; - -extern bool profileButtonDisabled; - -extern std::optional upPressedSince; -extern int upPressRepeat; -extern std::optional downPressedSince; -extern int downPressRepeat; - -class InputDispatcher -{ -public: - static void init(); - - static void update(); - - static void rotate(int offset); - - static void upButton(bool pressed); - - static void downButton(bool pressed); - - static void confirmButton(bool pressed); - - static void backButton(bool pressed); - - static void profileButton(uint8_t index, bool pressed); - - static void blinkLeftButton(bool pressed); - - static void blinkRightButton(bool pressed); - - static void quickActionButtonDown(bool pressed); - - static void quickActionButtonUp(bool pressed); -}; diff --git a/main/debuginputhandler.cpp b/main/debuginputhandler.cpp index 89bbeb9..76ceaf2 100644 --- a/main/debuginputhandler.cpp +++ b/main/debuginputhandler.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include // local includes #include "globals.h" @@ -22,6 +24,9 @@ constexpr const char * const TAG = "DEBUG"; uint8_t consoleControlCharsReceived{}; bool uart0Initialized{}; + +void handleNormalChar(char c); +void handleSpecialChar(char c); } // namespace void initDebugInput() @@ -70,112 +75,140 @@ void handleDebugInput() else consoleControlCharsReceived = 0; break; - case 'i': - case 'I': - consoleControlCharsReceived = 0; - espgui::tft.init(); - break; - case 'p': - case 'P': - { - consoleControlCharsReceived = 0; - const auto firstPower = controllers.front.command.poweroff; - for (Controller &controller : controllers) - controller.command.poweroff = !firstPower; - break; - } - case 'l': - case 'L': - { - consoleControlCharsReceived = 0; - const auto firstLed = controllers.front.command.led; - for (Controller &controller : controllers) - controller.command.led = !firstLed; - break; - } - case 'r': - case 'R': - consoleControlCharsReceived = 0; - loadSettings(); - break; - case 's': - case 'S': - consoleControlCharsReceived = 0; - saveSettings(); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - consoleControlCharsReceived = 0; - for (Controller &controller : controllers) - controller.command.buzzer.freq = c-'0'; - break; - case 'z': - case 'Z': - consoleControlCharsReceived = 0; - if (espgui::currentDisplay) - { - espgui::currentDisplay->buttonPressed(espgui::Button(BobbyButton::Left2)); - espgui::currentDisplay->buttonReleased(espgui::Button(BobbyButton::Left2)); - } - break; - case 'u': - case 'U': - consoleControlCharsReceived = 0; - if (espgui::currentDisplay) - { - espgui::currentDisplay->buttonPressed(espgui::Button(BobbyButton::Right2)); - espgui::currentDisplay->buttonReleased(espgui::Button(BobbyButton::Right2)); - } - break; default: consoleControlCharsReceived = 0; + handleNormalChar(c); } } else { consoleControlCharsReceived = 0; - switch (c) - { - case 'A': // Up arrow pressed - if (espgui::currentDisplay) - { - espgui::currentDisplay->buttonPressed(espgui::Button::Up); - espgui::currentDisplay->buttonReleased(espgui::Button::Up); - } - break; - case 'B': // Down arrow pressed - if (espgui::currentDisplay) - { - espgui::currentDisplay->buttonPressed(espgui::Button::Down); - espgui::currentDisplay->buttonReleased(espgui::Button::Down); - } - break; - case 'C': // Right arrow pressed - if (espgui::currentDisplay) - { - espgui::currentDisplay->buttonPressed(espgui::Button::Right); - espgui::currentDisplay->buttonReleased(espgui::Button::Right); - } - break; - case 'D': // Left arrow pressed - if (espgui::currentDisplay) - { - espgui::currentDisplay->buttonPressed(espgui::Button::Left); - espgui::currentDisplay->buttonReleased(espgui::Button::Left); - } - break; - default: - ESP_LOGI(TAG, "unknown control char received: %hhx", c); - } + handleSpecialChar(c); } } } } + +namespace { +void handleNormalChar(char c) +{ + if (auto display = espgui::currentDisplay ? espgui::currentDisplay->asChangeValueDisplayString() : nullptr) + { + switch (c) + { + case ' ' ... '~': + display->setShownValue(display->shownValue() + c); + break; + case 8: + if (auto val = display->shownValue(); !val.empty()) + { + val.pop_back(); + display->setShownValue(std::move(val)); + } + break; + default: + ESP_LOGW(TAG, "unknown char %hhx %c", c, c); + } + } + else + { + switch (c) + { + case 'i': + case 'I': + espgui::tft.init(); + break; + case 'p': + case 'P': + { + const auto firstPower = controllers.front.command.poweroff; + for (Controller &controller : controllers) + controller.command.poweroff = !firstPower; + break; + } + case 'l': + case 'L': + { + const auto firstLed = controllers.front.command.led; + for (Controller &controller : controllers) + controller.command.led = !firstLed; + break; + } + case 'r': + case 'R': + loadSettings(); + break; + case 's': + case 'S': + saveSettings(); + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + for (Controller &controller : controllers) + controller.command.buzzer.freq = c-'0'; + break; + case 'z': + case 'Z': + if (espgui::currentDisplay) + { + espgui::currentDisplay->buttonPressed(espgui::Button(BobbyButton::Left2)); + espgui::currentDisplay->buttonReleased(espgui::Button(BobbyButton::Left2)); + } + break; + case 'u': + case 'U': + if (espgui::currentDisplay) + { + espgui::currentDisplay->buttonPressed(espgui::Button(BobbyButton::Right2)); + espgui::currentDisplay->buttonReleased(espgui::Button(BobbyButton::Right2)); + } + break; + } + } +} + +void handleSpecialChar(char c) +{ + switch (c) + { + case 'A': // Up arrow pressed + if (espgui::currentDisplay) + { + espgui::currentDisplay->buttonPressed(espgui::Button::Up); + espgui::currentDisplay->buttonReleased(espgui::Button::Up); + } + break; + case 'B': // Down arrow pressed + if (espgui::currentDisplay) + { + espgui::currentDisplay->buttonPressed(espgui::Button::Down); + espgui::currentDisplay->buttonReleased(espgui::Button::Down); + } + break; + case 'C': // Right arrow pressed + if (espgui::currentDisplay) + { + espgui::currentDisplay->buttonPressed(espgui::Button::Right); + espgui::currentDisplay->buttonReleased(espgui::Button::Right); + } + break; + case 'D': // Left arrow pressed + if (espgui::currentDisplay) + { + espgui::currentDisplay->buttonPressed(espgui::Button::Left); + espgui::currentDisplay->buttonReleased(espgui::Button::Left); + } + break; + default: + ESP_LOGI(TAG, "unknown control char received: %hhx", c); + } +} +} // namespace diff --git a/main/displays/menus/wifiapsettingsmenu.cpp b/main/displays/menus/wifiapsettingsmenu.cpp index 3dffe9c..f9884fa 100644 --- a/main/displays/menus/wifiapsettingsmenu.cpp +++ b/main/displays/menus/wifiapsettingsmenu.cpp @@ -16,6 +16,7 @@ #include "displays/bobbychangevaluedisplay.h" #include "changevaluedisplay.h" #include "changevaluedisplay_string.h" +#include "changevaluedisplay_ip_address_t.h" #include "changevaluedisplay_wifi_auth_mode_t.h" #include "wifiapclientsmenu.h" #include "networksettingsmenu.h" @@ -33,17 +34,17 @@ constexpr char TEXT_DISABLEWHENONLINE[] = "Disable when online"; constexpr char TEXT_BACK[] = "Back"; constexpr char TEXT_SSID[] = "AP SSID"; -constexpr char TEXT_SSID_FORMATTED[] = "&sssid: &2"; +constexpr char TEXT_SSID_FORMATTED[] = "&sssid: "; constexpr char TEXT_KEY[] = "AP Key"; -constexpr char TEXT_KEY_FORMATTED[] = "&skey: &2"; +constexpr char TEXT_KEY_FORMATTED[] = "&skey: "; constexpr char TEXT_IP[] = "AP IP"; -constexpr char TEXT_IP_FORMATTED[] = "&sIP: &f&2"; +constexpr char TEXT_IP_FORMATTED[] = "&sIP: &f"; constexpr char TEXT_MASK[] = "AP Mask"; -constexpr char TEXT_MASK_FORMATTED[] = "&sMask: &f&2"; +constexpr char TEXT_MASK_FORMATTED[] = "&sMask: &f"; constexpr char TEXT_CHANNEL[] = "AP Channel"; -constexpr char TEXT_CHANNEL_FORMATTED[] = "&sChannel: &f&2"; +constexpr char TEXT_CHANNEL_FORMATTED[] = "&sChannel: &f"; constexpr char TEXT_AUTHMODE[] = "AP Authmode"; -constexpr char TEXT_AUTHMODE_FORMATTED[] = "&sAuthmode: &2"; +constexpr char TEXT_AUTHMODE_FORMATTED[] = "&sAuthmode: "; class WifiApClientsAction : public virtual ActionInterface { @@ -67,6 +68,22 @@ using ApKeyChangeScreen = espgui::makeComponent< espgui::BackActionInterface> >; +using ApIpChangeScreen = espgui::makeComponent< + BobbyChangeValueDisplay, + espgui::StaticText, + WifiApIpAccessor, + espgui::ConfirmActionInterface>, + espgui::BackActionInterface> +>; + +using ApMaskChangeScreen = espgui::makeComponent< + BobbyChangeValueDisplay, + espgui::StaticText, + WifiApMaskAccessor, + espgui::ConfirmActionInterface>, + espgui::BackActionInterface> +>; + using ApChannelChangeScreen = espgui::makeComponent< BobbyChangeValueDisplay, espgui::StaticText, @@ -87,17 +104,17 @@ using ApAuthmodeChangeScreen = espgui::makeComponent< WifiApSettingsMenu::WifiApSettingsMenu() { constructMenuItem, BobbyCheckbox, WifiApEnabledAccessor>>(); - //constructMenuItem, BobbyCheckbox, WifiApDisableWhenOnlineAccessor>>(); - constructMenuItem, SwitchScreenAction>>(); - constructMenuItem, SwitchScreenAction>>(); + //constructMenuItem, BobbyCheckbox, WifiApDisableWhenOnlineAccessor>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); constructMenuItem>(); - constructMenuItem, DummyAction>>(); - constructMenuItem, DummyAction>>(); - constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); - constructMenuItem>(); - constructMenuItem>(); - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&icons::back>>>(); + constructMenuItem>(); + constructMenuItem>(); + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&icons::back>>>(); } std::string WifiApSettingsMenu::text() const diff --git a/main/displays/menus/wifistaconfigentrymenu.cpp b/main/displays/menus/wifistaconfigentrymenu.cpp index ae0d271..ccdd01d 100644 --- a/main/displays/menus/wifistaconfigentrymenu.cpp +++ b/main/displays/menus/wifistaconfigentrymenu.cpp @@ -6,22 +6,96 @@ #include #include #include +#include +#include +#include +#include // local includes -#include "texthelpers/wifistaconfigtexthelpers.h" +#include "displays/bobbychangevaluedisplay.h" #include "accessors/wifistaconfigaccessors.h" #include "wifistaconfigsmenu.h" #include "newsettings.h" #include "bobbycheckbox.h" -using namespace espgui; - namespace { +constexpr char TEXT_SSID_TITLE[] = "WiFi {} SSID"; +constexpr char TEXT_SSID_FORMATTED[] = "&sSSID: &f"; +constexpr char TEXT_KEY_TITLE[] = "WiFi {} Key"; +constexpr char TEXT_KEY_FORMATTED[] = "&sKey: &f"; constexpr char TEXT_USESTATICIP[] = "Use Static Ip"; +constexpr char TEXT_STATICIP_TITLE[] = "WiFi {} Static Ip"; +constexpr char TEXT_STATICIP_FORMATTED[] = "&sStatic Ip: &f"; +constexpr char TEXT_STATICMASK_TITLE[] = "WiFi {} Static Mask"; +constexpr char TEXT_STATICMASK_FORMATTED[] = "&sStatic Mask: &f"; +constexpr char TEXT_STATICGW_TITLE[] = "WiFi {} Static Gw"; +constexpr char TEXT_STATICGW_FORMATTED[] = "&sStatic Gw: &f"; constexpr char TEXT_USESTATICDNS[] = "Use Static Dns"; +constexpr char TEXT_STATICDNS0_TITLE[] = "WiFi {} Static Dns0"; +constexpr char TEXT_STATICDNS0_FORMATTED[] = "&sStatic Dns0: &f"; +constexpr char TEXT_STATICDNS1_TITLE[] = "WiFi {} Static Dns1"; +constexpr char TEXT_STATICDNS1_FORMATTED[] = "&sStatic Dns1: &f"; +constexpr char TEXT_STATICDNS2_TITLE[] = "WiFi {} Static Dns2"; +constexpr char TEXT_STATICDNS2_FORMATTED[] = "&sStatic Dns2: &f"; constexpr char TEXT_DELETECONFIG[] = "Delete config"; constexpr char TEXT_BACK[] = "Back"; +template +class StaChangeScreen : + public BobbyChangeValueDisplay, + public Taccessor +{ +public: + explicit StaChangeScreen(int index) : Taccessor{index}, m_index{index} {} + std::string text() const override { return fmt::format(Ttitle, m_index + 1); } + void confirm() override { espgui::switchScreen(m_index); } + void back() override { espgui::switchScreen(m_index); } + +private: + const int m_index; +}; + +template +class StaChangeMenuItem : + public espgui::MenuItem, + public espgui::TextWithValueHelper +{ +public: + explicit StaChangeMenuItem(int index) : + espgui::TextWithValueHelper{index}, + m_index{index} + {} + + void triggered() override { espgui::switchScreen(m_index); } + +private: + const int m_index; +}; + +using StaSsidChangeScreen = StaChangeScreen; +using StaSsidMenuItem = StaChangeMenuItem; + +using StaKeyChangeScreen = StaChangeScreen; +using StaKeyMenuItem = StaChangeMenuItem; + +using StaStaticIpChangeScreen = StaChangeScreen; +using StaStaticIpMenuItem = StaChangeMenuItem; + +using StaStaticMaskChangeScreen = StaChangeScreen; +using StaStaticMaskMenuItem = StaChangeMenuItem; + +using StaStaticGwChangeScreen = StaChangeScreen; +using StaStaticGwMenuItem = StaChangeMenuItem; + +using StaStaticDns0ChangeScreen = StaChangeScreen; +using StaStaticDns0MenuItem = StaChangeMenuItem; + +using StaStaticDns1ChangeScreen = StaChangeScreen; +using StaStaticDns1MenuItem = StaChangeMenuItem; + +using StaStaticDns2ChangeScreen = StaChangeScreen; +using StaStaticDns2MenuItem = StaChangeMenuItem; + class ClearConfigAction : public virtual espgui::ActionInterface { public: @@ -37,16 +111,17 @@ private: WifiStaConfigEntryMenu::WifiStaConfigEntryMenu(int index) : m_index{index} { - constructMenuItem>(index); - constructMenuItem>(index); + using namespace espgui; + constructMenuItem(index); + constructMenuItem(index); constructMenuItem, BobbyCheckbox>>(index); - constructMenuItem>(index); - constructMenuItem>(index); - constructMenuItem>(index); + constructMenuItem(index); + constructMenuItem(index); + constructMenuItem(index); constructMenuItem, BobbyCheckbox>>(index); - constructMenuItem>(index); - constructMenuItem>(index); - constructMenuItem>(index); + constructMenuItem(index); + constructMenuItem(index); + constructMenuItem(index); constructMenuItem>>(index); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&icons::back>>>(); } @@ -58,7 +133,7 @@ std::string WifiStaConfigEntryMenu::text() const void WifiStaConfigEntryMenu::back() { - switchScreen(); + espgui::switchScreen(); } namespace { diff --git a/main/dpad.h b/main/dpad.h index 5fbe662..8f31f27 100644 --- a/main/dpad.h +++ b/main/dpad.h @@ -1,13 +1,19 @@ #pragma once +// system includes #include +// Arduino includes #include +// 3rdparty lib includes #include +#include -#include "buttons.h" +// local includes #include "types.h" +#include "newsettings.h" +#include "bobbybuttons.h" namespace { namespace dpad diff --git a/main/dpad3wire.h b/main/dpad3wire.h index c2403d7..c01978a 100644 --- a/main/dpad3wire.h +++ b/main/dpad3wire.h @@ -6,12 +6,14 @@ // 3rdparty lib includes #include #include +#include // local includes #include "dpad.h" -#include "buttons.h" #include "types.h" #include "globals.h" +#include "newsettings.h" +#include "bobbybuttons.h" namespace { namespace dpad3wire diff --git a/main/dpad5wire.cpp b/main/dpad5wire.cpp index e69de29..b37c7d2 100644 --- a/main/dpad5wire.cpp +++ b/main/dpad5wire.cpp @@ -0,0 +1,122 @@ +#include "dpad5wire.h" + +// system includes +#include + +// Arduino includes +#include + +// 3rdparty lib includes +#include +#include +#include + +// local includes +#include "types.h" +#include "globals.h" +#include "newsettings.h" +#include "bobbybuttons.h" + +namespace { +template +class Helper +{ +public: + static constexpr auto OutPin = OUT; + static constexpr auto In1Pin = IN1; + static constexpr auto In2Pin = IN2; + static constexpr auto In3Pin = IN3; + static constexpr auto In4Pin = IN4; + + void begin(); + + std::array read(); +}; + +template +void Helper::begin() +{ + pinMode(OUT, OUTPUT); +} + +template +std::array Helper::read() +{ + std::array result; + + digitalWrite(OUT, LOW); + + pinMode(IN1, INPUT_PULLUP); + pinMode(IN2, INPUT_PULLUP); + pinMode(IN3, INPUT_PULLUP); + pinMode(IN4, INPUT_PULLUP); + + vPortYield(); + + result[0] = digitalRead(IN1)==LOW; + result[1] = digitalRead(IN2)==LOW; + result[2] = digitalRead(IN3)==LOW; + result[3] = digitalRead(IN4)==LOW; + + digitalWrite(OUT, HIGH); + + pinMode(IN1, INPUT_PULLDOWN); + pinMode(IN2, INPUT_PULLDOWN); + pinMode(IN3, INPUT_PULLDOWN); + pinMode(IN4, INPUT_PULLDOWN); + + vPortYield(); + + result[4] = digitalRead(IN1); + result[5] = digitalRead(IN2); + result[6] = digitalRead(IN3); + result[7] = digitalRead(IN4); + + return result; +} + +#ifdef FEATURE_DPAD_5WIRESW +Helper helper; +std::array lastState; +std::array debounce; +#endif +} // namespace + +#ifdef FEATURE_DPAD_5WIRESW +namespace dpad5wire { +void init() +{ + helper.begin(); + std::fill(std::begin(lastState), std::end(lastState), false); + std::fill(std::begin(debounce), std::end(debounce), espchrono::millis_clock::now()); +} + +void update() +{ + const auto newState = helper.read(); + +#ifdef DPAD_5WIRESW_DEBUG + lastState = newState; + return; +#endif + + const auto now = espchrono::millis_clock::now(); + + const std::chrono::milliseconds dpadDebounce{settings.boardcomputerHardware.dpadDebounce}; + + for (auto i = 0; i < 8; i++) + if (lastState[i] != newState[i] && now - debounce[i] > dpadDebounce) + { + lastState[i] = newState[i]; + if (espgui::currentDisplay) + { + if (newState[i]) + espgui::currentDisplay->rawButtonPressed(i); + else + espgui::currentDisplay->rawButtonReleased(i); + } + debounce[i] = now; + } +} +} // namespace dpad5wire +#endif diff --git a/main/dpad5wire.h b/main/dpad5wire.h index 1296e8c..f28c3b5 100644 --- a/main/dpad5wire.h +++ b/main/dpad5wire.h @@ -1,188 +1,8 @@ #pragma once -// system includes -#include - -// Arduino includes -#include - -// 3rdparty lib includes -#include -#include - -// local includes -#include "buttons.h" -#include "types.h" -#include "globals.h" - -namespace { -namespace dpad5wire { #ifdef FEATURE_DPAD_5WIRESW -class State : public std::array -{ -public: - State() : std::array{false, false, false, false, false, false, false, false} {} - State(const std::array &other) : std::array{} {} - - State &operator=(const std::array &other) - { - std::array::operator=(other); - return *this; - } - - State &operator=(const State &other) - { - std::array::operator=(other); - return *this; - } - - bool &up{this->at(DPAD_5WIRESW_UP)}; - bool &down{this->at(DPAD_5WIRESW_DOWN)}; - bool &confirm{this->at(DPAD_5WIRESW_CONFIRM)}; - bool &back{this->at(DPAD_5WIRESW_BACK)}; - bool &profile0{this->at(DPAD_5WIRESW_PROFILE0)}; - bool &profile1{this->at(DPAD_5WIRESW_PROFILE1)}; - bool &profile2{this->at(DPAD_5WIRESW_PROFILE2)}; - bool &profile3{this->at(DPAD_5WIRESW_PROFILE3)}; -}; - -template -class Helper -{ -public: - static constexpr auto OutPin = OUT; - static constexpr auto In1Pin = IN1; - static constexpr auto In2Pin = IN2; - static constexpr auto In3Pin = IN3; - static constexpr auto In4Pin = IN4; - - void begin(); - - State read(); -}; - -template -void Helper::begin() -{ - pinMode(OUT, OUTPUT); -} - -template -State Helper::read() -{ - State result; - - digitalWrite(OUT, LOW); - - pinMode(IN1, INPUT_PULLUP); - pinMode(IN2, INPUT_PULLUP); - pinMode(IN3, INPUT_PULLUP); - pinMode(IN4, INPUT_PULLUP); - - vPortYield(); - - result[0] = digitalRead(IN1)==LOW; - result[1] = digitalRead(IN2)==LOW; - result[2] = digitalRead(IN3)==LOW; - result[3] = digitalRead(IN4)==LOW; - - digitalWrite(OUT, HIGH); - - pinMode(IN1, INPUT_PULLDOWN); - pinMode(IN2, INPUT_PULLDOWN); - pinMode(IN3, INPUT_PULLDOWN); - pinMode(IN4, INPUT_PULLDOWN); - - vPortYield(); - - result[4] = digitalRead(IN1); - result[5] = digitalRead(IN2); - result[6] = digitalRead(IN3); - result[7] = digitalRead(IN4); - - return result; -} - -Helper helper; -State lastState; -espchrono::millis_clock::time_point debounceUp, debounceDown, debounceConfirm, debounceBack, debounceProfile0, debounceProfile1, debounceProfile2, debounceProfile3; - -void init() -{ - helper.begin(); - debounceUp = debounceDown = debounceConfirm = debounceBack = debounceProfile0 = debounceProfile1 = debounceProfile2 = debounceProfile3 = espchrono::millis_clock::now(); -} - -void update() -{ - const auto newState = helper.read(); - -#ifdef DPAD_5WIRESW_DEBUG - lastState = newState; - return; -#endif - - const auto now = espchrono::millis_clock::now(); - - const std::chrono::milliseconds dpadDebounce{settings.boardcomputerHardware.dpadDebounce}; - - if (lastState.up != newState.up && now - debounceUp > dpadDebounce) - { - lastState.up = newState.up; - InputDispatcher::upButton(newState.up); - debounceUp = now; - } - - if (lastState.down != newState.down && now - debounceDown > dpadDebounce) - { - lastState.down = newState.down; - InputDispatcher::downButton(newState.down); - debounceDown = now; - } - - if (lastState.confirm != newState.confirm && now - debounceConfirm > dpadDebounce) - { - lastState.confirm = newState.confirm; - InputDispatcher::confirmButton(newState.confirm); - debounceConfirm = now; - } - - if (lastState.back != newState.back && now - debounceBack > dpadDebounce) - { - lastState.back = newState.back; - InputDispatcher::backButton(newState.back); - debounceBack = now; - } - - if (lastState.profile0 != newState.profile0 && now - debounceProfile0 > dpadDebounce) - { - lastState.profile0 = newState.profile0; - InputDispatcher::profileButton(0, newState.profile0); - debounceProfile0 = now; - } - - if (lastState.profile1 != newState.profile1 && now - debounceProfile1 > dpadDebounce) - { - lastState.profile1 = newState.profile1; - InputDispatcher::profileButton(1, newState.profile1); - debounceProfile1 = now; - } - - if (lastState.profile2 != newState.profile2 && now - debounceProfile2 > dpadDebounce) - { - lastState.profile2 = newState.profile2; - InputDispatcher::profileButton(2, newState.profile2); - debounceProfile2 = now; - } - - if (lastState.profile3 != newState.profile3 && now - debounceProfile3 > dpadDebounce) - { - lastState.profile3 = newState.profile3; - InputDispatcher::profileButton(3, newState.profile3); - debounceProfile3 = now; - } -} -#endif - +namespace dpad5wire { +void init(); +void update(); } // namespace dpad5wire -} // namespace +#endif diff --git a/main/dpad5wire_2out.cpp b/main/dpad5wire_2out.cpp index e69de29..880a245 100644 --- a/main/dpad5wire_2out.cpp +++ b/main/dpad5wire_2out.cpp @@ -0,0 +1,145 @@ +#include "dpad5wire_2out.h" + +// system includes +#include + +// Arduino includes +#include + +// 3rdparty lib includes +#include +#include +#include + +// local includes +#include "types.h" +#include "globals.h" +#include "newsettings.h" +#include "bobbybuttons.h" + +namespace { +template +class Helper +{ +public: + static constexpr auto OutPin = OUT; + static constexpr auto In1Pin = IN1; + static constexpr auto In2Pin = IN2; + static constexpr auto In3Pin = IN3; + static constexpr auto In4Pin = IN4; + + void begin(); + + std::array read(); +}; + +template +void Helper::begin() +{ +} + +template +std::array Helper::read() +{ + std::array result; + + pinMode(OUT1, OUTPUT); + pinMode(OUT2, INPUT); + + digitalWrite(OUT1, LOW); + + pinMode(IN1, INPUT_PULLUP); + pinMode(IN2, INPUT_PULLUP); + pinMode(IN3, INPUT_PULLUP); + + vPortYield(); + + result[0] = digitalRead(IN1)==LOW; + result[1] = digitalRead(IN2)==LOW; + result[2] = digitalRead(IN3)==LOW; + + digitalWrite(OUT1, HIGH); + + pinMode(IN1, INPUT_PULLDOWN); + pinMode(IN2, INPUT_PULLDOWN); + pinMode(IN3, INPUT_PULLDOWN); + + vPortYield(); + + result[3] = digitalRead(IN1); + result[4] = digitalRead(IN2); + result[5] = digitalRead(IN3); + + pinMode(OUT1, INPUT); + pinMode(OUT2, OUTPUT); + + digitalWrite(OUT2, LOW); + + pinMode(IN1, INPUT_PULLUP); + pinMode(IN2, INPUT_PULLUP); + pinMode(IN3, INPUT_PULLUP); + + vPortYield(); + + result[6] = digitalRead(IN1)==LOW; + result[7] = digitalRead(IN2)==LOW; + result[8] = digitalRead(IN3)==LOW; + + digitalWrite(OUT2, HIGH); + + pinMode(IN1, INPUT_PULLDOWN); + pinMode(IN2, INPUT_PULLDOWN); + pinMode(IN3, INPUT_PULLDOWN); + + vPortYield(); + + result[9] = digitalRead(IN1); + result[10] = digitalRead(IN2); + result[11] = digitalRead(IN3); + + return result; +} + +#ifdef FEATURE_DPAD_5WIRESW_2OUT +Helper helper; +std::array lastState; +std::array debounce; +#endif +} // namespace + +#ifdef FEATURE_DPAD_5WIRESW_2OUT + +namespace dpad5wire_2out { +void init() +{ + helper.begin(); + std::fill(std::begin(lastState), std::end(lastState), false); + std::fill(std::begin(debounce), std::end(debounce), espchrono::millis_clock::now()); +} + +void update() +{ + const auto newState = helper.read(); + + const auto now = espchrono::millis_clock::now(); + + const std::chrono::milliseconds dpadDebounce{configs.dpadDebounce.value}; + + for (auto i = 0; i < 12; i++) + if (lastState[i] != newState[i] && now - debounce[i] > dpadDebounce) + { + lastState[i] = newState[i]; + if (espgui::currentDisplay) + { + if (newState[i]) + espgui::currentDisplay->rawButtonPressed(i); + else + espgui::currentDisplay->rawButtonReleased(i); + } + debounce[i] = now; + } +} + +} // namespace dpad5wire_2out + +#endif diff --git a/main/dpad5wire_2out.h b/main/dpad5wire_2out.h index db41d9d..1a9c555 100644 --- a/main/dpad5wire_2out.h +++ b/main/dpad5wire_2out.h @@ -1,260 +1,8 @@ #pragma once -// system includes -#include - -// Arduino includes -#include - -// 3rdparty lib includes -#include -#include - -// local includes -#include "buttons.h" -#include "types.h" -#include "globals.h" -#include "newsettings.h" - -namespace { -namespace dpad5wire_2out { - #ifdef FEATURE_DPAD_5WIRESW_2OUT -class State : public std::array -{ -public: - State() : std::array{false, false, false, false, false, false, false, false, false, false, false, false} {} - State(const std::array &other) : std::array{} {} - - State &operator=(const std::array &other) - { - std::array::operator=(other); - return *this; - } - - State &operator=(const State &other) - { - std::array::operator=(other); - return *this; - } - - bool &up{this->at(DPAD_5WIRESW_UP)}; - bool &down{this->at(DPAD_5WIRESW_DOWN)}; - bool &confirm{this->at(DPAD_5WIRESW_CONFIRM)}; - bool &back{this->at(DPAD_5WIRESW_BACK)}; - bool &profile0{this->at(DPAD_5WIRESW_PROFILE0)}; - bool &profile1{this->at(DPAD_5WIRESW_PROFILE1)}; - bool &profile2{this->at(DPAD_5WIRESW_PROFILE2)}; - bool &profile3{this->at(DPAD_5WIRESW_PROFILE3)}; - - bool &blink_left{this->at(DPAD_5WIRESW_BLINK_LEFT)}; - bool &blink_right{this->at(DPAD_5WIRESW_BLINK_RIGHT)}; - bool &quickaction_down{this->at(DPAD_5WIRESW_QUICKACTION_DOWN)}; - bool &quickaction_up{this->at(DPAD_5WIRESW_QUICKACTION_UP)}; -}; - -template -class Helper -{ -public: - static constexpr auto OutPin = OUT; - static constexpr auto In1Pin = IN1; - static constexpr auto In2Pin = IN2; - static constexpr auto In3Pin = IN3; - static constexpr auto In4Pin = IN4; - - void begin(); - - State read(); -}; - -template -void Helper::begin() -{ -} - -template -State Helper::read() -{ - State result; - - pinMode(OUT1, OUTPUT); - pinMode(OUT2, INPUT); - - digitalWrite(OUT1, LOW); - - pinMode(IN1, INPUT_PULLUP); - pinMode(IN2, INPUT_PULLUP); - pinMode(IN3, INPUT_PULLUP); - - vPortYield(); - - result[0] = digitalRead(IN1)==LOW; - result[1] = digitalRead(IN2)==LOW; - result[2] = digitalRead(IN3)==LOW; - - digitalWrite(OUT1, HIGH); - - pinMode(IN1, INPUT_PULLDOWN); - pinMode(IN2, INPUT_PULLDOWN); - pinMode(IN3, INPUT_PULLDOWN); - - vPortYield(); - - result[3] = digitalRead(IN1); - result[4] = digitalRead(IN2); - result[5] = digitalRead(IN3); - - pinMode(OUT1, INPUT); - pinMode(OUT2, OUTPUT); - - digitalWrite(OUT2, LOW); - - pinMode(IN1, INPUT_PULLUP); - pinMode(IN2, INPUT_PULLUP); - pinMode(IN3, INPUT_PULLUP); - - vPortYield(); - - result[6] = digitalRead(IN1)==LOW; - result[7] = digitalRead(IN2)==LOW; - result[8] = digitalRead(IN3)==LOW; - - digitalWrite(OUT2, HIGH); - - pinMode(IN1, INPUT_PULLDOWN); - pinMode(IN2, INPUT_PULLDOWN); - pinMode(IN3, INPUT_PULLDOWN); - - vPortYield(); - - result[9] = digitalRead(IN1); - result[10] = digitalRead(IN2); - result[11] = digitalRead(IN3); - - return result; -} - -Helper helper; -State lastState; -espchrono::millis_clock::time_point debounceUp, debounceDown, debounceConfirm, debounceBack, debounceProfile0, debounceProfile1, debounceProfile2, debounceProfile3, debounceBlinkLeft, debounceBlinkRight, debounceQuickactionDown, debounceQuickactionUp; - -void init() -{ - helper.begin(); - debounceUp = - debounceDown = - debounceConfirm = - debounceBack = - debounceProfile0 = - debounceProfile1 = - debounceProfile2 = - debounceProfile3 = - debounceBlinkLeft= - debounceBlinkRight = - debounceQuickactionDown = - debounceQuickactionUp = - espchrono::millis_clock::now(); -} - -void update() -{ - const auto newState = helper.read(); - -#ifdef DPAD_5WIRESW_DEBUG - lastState = newState; - return; -#endif - - const auto now = espchrono::millis_clock::now(); - - const std::chrono::milliseconds dpadDebounce{configs.dpadDebounce.value}; - - if (lastState.up != newState.up && now - debounceUp > dpadDebounce) - { - lastState.up = newState.up; - InputDispatcher::upButton(newState.up); - debounceUp = now; - } - - if (lastState.down != newState.down && now - debounceDown > dpadDebounce) - { - lastState.down = newState.down; - InputDispatcher::downButton(newState.down); - debounceDown = now; - } - - if (lastState.confirm != newState.confirm && now - debounceConfirm > dpadDebounce) - { - lastState.confirm = newState.confirm; - InputDispatcher::confirmButton(newState.confirm); - debounceConfirm = now; - } - - if (lastState.back != newState.back && now - debounceBack > dpadDebounce) - { - lastState.back = newState.back; - InputDispatcher::backButton(newState.back); - debounceBack = now; - } - - if (lastState.profile0 != newState.profile0 && now - debounceProfile0 > dpadDebounce) - { - lastState.profile0 = newState.profile0; - InputDispatcher::profileButton(0, newState.profile0); - debounceProfile0 = now; - } - - if (lastState.profile1 != newState.profile1 && now - debounceProfile1 > dpadDebounce) - { - lastState.profile1 = newState.profile1; - InputDispatcher::profileButton(1, newState.profile1); - debounceProfile1 = now; - } - - if (lastState.profile2 != newState.profile2 && now - debounceProfile2 > dpadDebounce) - { - lastState.profile2 = newState.profile2; - InputDispatcher::profileButton(2, newState.profile2); - debounceProfile2 = now; - } - - if (lastState.profile3 != newState.profile3 && now - debounceProfile3 > dpadDebounce) - { - lastState.profile3 = newState.profile3; - InputDispatcher::profileButton(3, newState.profile3); - debounceProfile3 = now; - } - - if (lastState.blink_left != newState.blink_left && now - debounceBlinkLeft > dpadDebounce) - { - lastState.blink_left = newState.blink_left; - InputDispatcher::blinkLeftButton(newState.blink_left); - debounceBlinkLeft = now; - } - - if (lastState.blink_right != newState.blink_right && now - debounceBlinkRight > dpadDebounce) - { - lastState.blink_right = newState.blink_right; - InputDispatcher::blinkRightButton(newState.blink_right); - debounceBlinkRight = now; - } - - if (lastState.quickaction_down != newState.quickaction_down && now - debounceQuickactionDown > dpadDebounce) - { - lastState.quickaction_down = newState.quickaction_down; - InputDispatcher::quickActionButtonDown(newState.quickaction_down); - debounceQuickactionDown = now; - } - - if (lastState.quickaction_up != newState.quickaction_up && now - debounceQuickactionUp > dpadDebounce) - { - lastState.quickaction_up = newState.quickaction_up; - InputDispatcher::quickActionButtonUp(newState.quickaction_up); - debounceQuickactionUp = now; - } -} -#endif - +namespace dpad5wire_2out { +void init(); +void update(); } // namespace dpad5wire_2out -} // namespace +#endif diff --git a/main/dpad6wire.cpp b/main/dpad6wire.cpp index e69de29..a52a4c7 100644 --- a/main/dpad6wire.cpp +++ b/main/dpad6wire.cpp @@ -0,0 +1,134 @@ +#include "dpad6wire.h" + +// system includes +#include + +// Arduino includes +#include + +// 3rdparty lib includes +#include +#include +#include + +// local includes +#include "types.h" +#include "globals.h" +#include "newsettings.h" +#include "bobbybuttons.h" + +namespace { +template +class Helper +{ +public: + static constexpr auto OutPin = OUT; + static constexpr auto In1Pin = IN1; + static constexpr auto In2Pin = IN2; + static constexpr auto In3Pin = IN3; + static constexpr auto In4Pin = IN4; + static constexpr auto In5Pin = IN5; + + void begin(); + + std::array read(); +}; + +template +void Helper::begin() +{ + pinMode(OUT, OUTPUT); +} + +template +std::array Helper::read() +{ + std::array result; + + digitalWrite(OUT, LOW); + + pinMode(IN1, INPUT_PULLUP); + pinMode(IN2, INPUT_PULLUP); + pinMode(IN3, INPUT_PULLUP); + pinMode(IN4, INPUT_PULLUP); + pinMode(IN5, INPUT_PULLUP); + + vPortYield(); + + result[0] = digitalRead(IN1)==LOW; + result[1] = digitalRead(IN2)==LOW; + result[2] = digitalRead(IN3)==LOW; + result[3] = digitalRead(IN4)==LOW; + result[8] = digitalRead(IN5)==LOW; + + digitalWrite(OUT, HIGH); + + pinMode(IN1, INPUT_PULLDOWN); + pinMode(IN2, INPUT_PULLDOWN); + pinMode(IN3, INPUT_PULLDOWN); + pinMode(IN4, INPUT_PULLDOWN); + pinMode(IN5, INPUT_PULLDOWN); + + vPortYield(); + + result[4] = digitalRead(IN1); + result[5] = digitalRead(IN2); + result[6] = digitalRead(IN3); + result[7] = digitalRead(IN4); + result[9] = digitalRead(IN5); + +#ifdef FEATURE_GSCHISSENE_DIODE + if (result[8] && result[9]) result[9] = 0; +#endif + + return result; +} + +#ifdef FEATURE_DPAD_6WIRESW +Helper helper; +std::array lastState; +std::array debounce; +#endif +} // namespace + +#ifdef FEATURE_DPAD_6WIRESW +namespace dpad6wire { + +void init() +{ + helper.begin(); + std::fill(std::begin(lastState), std::end(lastState), false); + std::fill(std::begin(debounce), std::end(debounce), espchrono::millis_clock::now()); +} + +void update() +{ + const auto newState = helper.read(); + +#ifdef DPAD_6WIRESW_DEBUG + lastState = newState; + return; +#endif + + const auto now = espchrono::millis_clock::now(); + + const std::chrono::milliseconds dpadDebounce{configs.dpadDebounce.value}; + + for (auto i = 0; i < 10; i++) + if (lastState[i] != newState[i] && now - debounce[i] > dpadDebounce) + { + lastState[i] = newState[i]; + if (espgui::currentDisplay) + { + if (newState[i]) + espgui::currentDisplay->rawButtonPressed(i); + else + espgui::currentDisplay->rawButtonReleased(i); + } + debounce[i] = now; + } +} + +} // namespace dpad6wire + +#endif diff --git a/main/dpad6wire.h b/main/dpad6wire.h index 643095b..c5ed317 100644 --- a/main/dpad6wire.h +++ b/main/dpad6wire.h @@ -1,214 +1,8 @@ #pragma once -// system includes -#include -// Arduino includes -#include - -// 3rdparty lib includes -#include -#include - -// local includes -#include "buttons.h" -#include "types.h" -#include "globals.h" -#include "newsettings.h" - -namespace { -namespace dpad6wire { #ifdef FEATURE_DPAD_6WIRESW -class State : public std::array -{ -public: - State() : std::array{false, false, false, false, false, false, false, false, false, false} {} - State(const std::array &other) : std::array{} {} - - State &operator=(const std::array &other) - { - std::array::operator=(other); - return *this; - } - - State &operator=(const State &other) - { - std::array::operator=(other); - return *this; - } - - bool &up{this->at(DPAD_6WIRESW_UP)}; - bool &down{this->at(DPAD_6WIRESW_DOWN)}; - bool &confirm{this->at(DPAD_6WIRESW_CONFIRM)}; - bool &back{this->at(DPAD_6WIRESW_BACK)}; - bool &profile0{this->at(DPAD_6WIRESW_PROFILE0)}; - bool &profile1{this->at(DPAD_6WIRESW_PROFILE1)}; - bool &profile2{this->at(DPAD_6WIRESW_PROFILE2)}; - bool &profile3{this->at(DPAD_6WIRESW_PROFILE3)}; - - bool &blink_left{this->at(DPAD_6WIRESW_BLINK_LEFT)}; - bool &blink_right{this->at(DPAD_6WIRESW_BLINK_RIGHT)}; -}; - -template -class Helper -{ -public: - static constexpr auto OutPin = OUT; - static constexpr auto In1Pin = IN1; - static constexpr auto In2Pin = IN2; - static constexpr auto In3Pin = IN3; - static constexpr auto In4Pin = IN4; - static constexpr auto In5Pin = IN5; - - void begin(); - - State read(); -}; - -template -void Helper::begin() -{ - pinMode(OUT, OUTPUT); -} - -template -State Helper::read() -{ - State result; - - digitalWrite(OUT, LOW); - - pinMode(IN1, INPUT_PULLUP); - pinMode(IN2, INPUT_PULLUP); - pinMode(IN3, INPUT_PULLUP); - pinMode(IN4, INPUT_PULLUP); - pinMode(IN5, INPUT_PULLUP); - - vPortYield(); - - result[0] = digitalRead(IN1)==LOW; - result[1] = digitalRead(IN2)==LOW; - result[2] = digitalRead(IN3)==LOW; - result[3] = digitalRead(IN4)==LOW; - result[8] = digitalRead(IN5)==LOW; - - digitalWrite(OUT, HIGH); - - pinMode(IN1, INPUT_PULLDOWN); - pinMode(IN2, INPUT_PULLDOWN); - pinMode(IN3, INPUT_PULLDOWN); - pinMode(IN4, INPUT_PULLDOWN); - pinMode(IN5, INPUT_PULLDOWN); - - vPortYield(); - - result[4] = digitalRead(IN1); - result[5] = digitalRead(IN2); - result[6] = digitalRead(IN3); - result[7] = digitalRead(IN4); - result[9] = digitalRead(IN5); - -#ifdef FEATURE_GSCHISSENE_DIODE - if (result[8] && result[9]) result[9] = 0; -#endif - - return result; -} - -Helper helper; -State lastState; -espchrono::millis_clock::time_point debounceUp, debounceDown, debounceConfirm, debounceBack, debounceProfile0, debounceProfile1, debounceProfile2, debounceProfile3, debounceBlinkLeft, debounceBlinkRight; - -void init() -{ - helper.begin(); - debounceUp = debounceDown = debounceConfirm = debounceBack = debounceProfile0 = debounceProfile1 = debounceProfile2 = debounceProfile3 = debounceBlinkLeft = debounceBlinkRight = espchrono::millis_clock::now(); -} - -void update() -{ - const auto newState = helper.read(); - -#ifdef DPAD_6WIRESW_DEBUG - lastState = newState; - return; -#endif - - const auto now = espchrono::millis_clock::now(); - - const std::chrono::milliseconds dpadDebounce{configs.dpadDebounce.value}; - - if (lastState.up != newState.up && now - debounceUp > dpadDebounce) - { - lastState.up = newState.up; - InputDispatcher::upButton(newState.up); - debounceUp = now; - } - - if (lastState.down != newState.down && now - debounceDown > dpadDebounce) - { - lastState.down = newState.down; - InputDispatcher::downButton(newState.down); - debounceDown = now; - } - - if (lastState.confirm != newState.confirm && now - debounceConfirm > dpadDebounce) - { - lastState.confirm = newState.confirm; - InputDispatcher::confirmButton(newState.confirm); - debounceConfirm = now; - } - - if (lastState.back != newState.back && now - debounceBack > dpadDebounce) - { - lastState.back = newState.back; - InputDispatcher::backButton(newState.back); - debounceBack = now; - } - - if (lastState.profile0 != newState.profile0 && now - debounceProfile0 > dpadDebounce) - { - lastState.profile0 = newState.profile0; - InputDispatcher::profileButton(0, newState.profile0); - debounceProfile0 = now; - } - - if (lastState.profile1 != newState.profile1 && now - debounceProfile1 > dpadDebounce) - { - lastState.profile1 = newState.profile1; - InputDispatcher::profileButton(1, newState.profile1); - debounceProfile1 = now; - } - - if (lastState.profile2 != newState.profile2 && now - debounceProfile2 > dpadDebounce) - { - lastState.profile2 = newState.profile2; - InputDispatcher::profileButton(2, newState.profile2); - debounceProfile2 = now; - } - - if (lastState.profile3 != newState.profile3 && now - debounceProfile3 > dpadDebounce) - { - lastState.profile3 = newState.profile3; - InputDispatcher::profileButton(3, newState.profile3); - debounceProfile3 = now; - } - - if (lastState.blink_left != newState.blink_left && now - debounceBlinkLeft > dpadDebounce) - { - lastState.blink_left = newState.blink_left; - InputDispatcher::blinkLeftButton(newState.blink_left); - debounceBlinkLeft = now; - } - - if (lastState.blink_right != newState.blink_right && now - debounceBlinkRight > dpadDebounce) - { - lastState.blink_right = newState.blink_right; - InputDispatcher::blinkRightButton(newState.blink_right); - debounceBlinkRight = now; - } -} -#endif - +namespace dpad6wire { +void init(); +void update(); } // namespace dpad6wire -} // namespace +#endif diff --git a/main/ledstrip.cpp b/main/ledstrip.cpp index ace5d5f..dca4196 100644 --- a/main/ledstrip.cpp +++ b/main/ledstrip.cpp @@ -18,12 +18,12 @@ std::vector leds; uint8_t gHue = 0; uint16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE; -uint16_t animation_type = LedstripAnimation::DefaultRainbow; +LedstripAnimation animation_type = LedstripAnimation::DefaultRainbow; void initLedStrip() { - animation_type = settings.ledstrip.animationType; + animation_type = LedstripAnimation(settings.ledstrip.animationType); leds.resize(settings.ledstrip.ledsCount); FastLED.addLeds(&*std::begin(leds), leds.size()) .setCorrection(TypicalSMD5050); diff --git a/main/ledstrip.h b/main/ledstrip.h index 2041841..ed1e446 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -6,6 +6,9 @@ // 3rdparty lib includes #include +// local includes +#include "ledstripdefines.h" + #ifdef FEATURE_LEDSTRIP enum Bobbycar_Side { @@ -32,7 +35,7 @@ extern std::vector leds; extern uint8_t gHue; extern uint16_t blinkAnimation; -extern uint16_t animation_type; +extern LedstripAnimation animation_type; void showDefaultLedstrip(); void showAnimation(); diff --git a/main/ledstripdefines.h b/main/ledstripdefines.h index 5582ca9..2713e4b 100644 --- a/main/ledstripdefines.h +++ b/main/ledstripdefines.h @@ -14,7 +14,8 @@ #endif #define LEDSTRIP_OVERWRITE_BLINKBOTH 3 -enum LedstripAnimation : uint16_t { +enum LedstripAnimation : uint8_t +{ DefaultRainbow, BetterRainbow, SpeedSync, diff --git a/main/screens.cpp b/main/screens.cpp index 11c4ef3..38e36f6 100644 --- a/main/screens.cpp +++ b/main/screens.cpp @@ -8,7 +8,6 @@ #include "globals.h" #include "utils.h" #include "icons/logo.h" -#include "buttons.h" using namespace espgui; @@ -28,58 +27,6 @@ void initScreen() void updateDisplay() { - if (rotated) - { - const auto rotatedCopy = rotated; - rotated = 0; - - if (currentDisplay) - { - if (rotatedCopy < 0) - currentDisplay->buttonPressed(espgui::Button::Up); - else - currentDisplay->buttonPressed(espgui::Button::Down); - } - } - - if (requestFullRedraw) - { - requestFullRedraw = false; - - tft.init(); - - if (currentDisplay) - currentDisplay->initScreen(); - } - - if (confirmButtonPressed) - { - confirmButtonPressed = false; - - if (currentDisplay) - currentDisplay->buttonPressed(espgui::Button::Right); - } - - if (confirmButtonLongPressed) - { - confirmButtonLongPressed = false; - //Serial.println("todo: implement long press for confirm"); - } - - if (backButtonPressed) - { - backButtonPressed = false; - - if (currentDisplay) - currentDisplay->buttonPressed(espgui::Button::Left); - } - - if (backButtonLongPressed) - { - backButtonLongPressed = false; - //Serial.println("todo: implement long press for back"); - } - if (currentDisplay) currentDisplay->update(); diff --git a/main/settingsutils.cpp b/main/settingsutils.cpp index 3f8967e..bff90f8 100644 --- a/main/settingsutils.cpp +++ b/main/settingsutils.cpp @@ -35,4 +35,4 @@ void switchProfile(uint8_t index) return; } } -} // namespace +} // namespace settingsutils diff --git a/main/settingsutils.h b/main/settingsutils.h index 54dba3d..248cad7 100644 --- a/main/settingsutils.h +++ b/main/settingsutils.h @@ -4,4 +4,4 @@ namespace settingsutils { void switchProfile(uint8_t index); -} +} // namespace settingsutils diff --git a/main/taskmanager.cpp b/main/taskmanager.cpp index 2330cc8..04ffdb8 100644 --- a/main/taskmanager.cpp +++ b/main/taskmanager.cpp @@ -14,7 +14,6 @@ // local includes #include "wifi_bobbycar.h" -#include "buttons.h" #include "dpad.h" #ifdef FEATURE_DPAD_3WIRESW #include "dpad3wire.h" @@ -88,7 +87,6 @@ void not_needed() {} espcpputils::SchedulerTask schedulerTasksArr[] { espcpputils::SchedulerTask { "wifi", wifi_begin, wifi_update, 100ms }, - espcpputils::SchedulerTask { "input", InputDispatcher::init, InputDispatcher::update, 20ms }, #ifdef FEATURE_DPAD espcpputils::SchedulerTask { "dpad", dpad::init, dpad::update, 20ms }, #endif diff --git a/main/texthelpers/wifistaconfigtexthelpers.cpp b/main/texthelpers/wifistaconfigtexthelpers.cpp deleted file mode 100644 index cc979c5..0000000 --- a/main/texthelpers/wifistaconfigtexthelpers.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "wifistaconfigtexthelpers.h" - -// 3rdparty lib includes -#include -#include -#include - -// local includes -#include "newsettings.h" - -using namespace espgui; - -std::string WifiStaConfigSsidText::text() const -{ - return fmt::format("&sssid: &f{}", richTextEscape(configs.wifi_configs[m_index].ssid.value)); -} - -std::string WifiStaConfigKeyText::text() const -{ - return fmt::format("&skey: &f{}", richTextEscape(configs.wifi_configs[m_index].key.value)); -} - -std::string WifiStaConfigStaticIpText::text() const -{ - return fmt::format("&sStatic Ip: &f{}", wifi_stack::toString(configs.wifi_configs[m_index].staticIp.value)); -} - -std::string WifiStaConfigStaticSubnetText::text() const -{ - return fmt::format("&sStatic Mask: &f{}", wifi_stack::toString(configs.wifi_configs[m_index].staticSubnet.value)); -} - -std::string WifiStaConfigStaticGatewayText::text() const -{ - return fmt::format("&sStatic Gw: &f{}", wifi_stack::toString(configs.wifi_configs[m_index].staticGateway.value)); -} - -std::string WifiStaConfigStaticDns0Text::text() const -{ - return fmt::format("&sStatic Dns0: &f{}", wifi_stack::toString(configs.wifi_configs[m_index].staticDns0.value)); -} - -std::string WifiStaConfigStaticDns1Text::text() const -{ - return fmt::format("&sStatic Dns1: &f{}", wifi_stack::toString(configs.wifi_configs[m_index].staticDns1.value)); -} - -std::string WifiStaConfigStaticDns2Text::text() const -{ - return fmt::format("&sStatic Dns2: &f{}", wifi_stack::toString(configs.wifi_configs[m_index].staticDns2.value)); -} diff --git a/main/texthelpers/wifistaconfigtexthelpers.h b/main/texthelpers/wifistaconfigtexthelpers.h deleted file mode 100644 index 5b11e55..0000000 --- a/main/texthelpers/wifistaconfigtexthelpers.h +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -// 3rdparty lib includes -#include - -class WifiStaConfigSsidText : public virtual espgui::TextInterface -{ -public: - WifiStaConfigSsidText(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -}; - -class WifiStaConfigKeyText : public virtual espgui::TextInterface -{ -public: - WifiStaConfigKeyText(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -}; - -class WifiStaConfigStaticIpText : public virtual espgui::TextInterface -{ -public: - WifiStaConfigStaticIpText(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -}; - -class WifiStaConfigStaticSubnetText : public virtual espgui::TextInterface -{ -public: - WifiStaConfigStaticSubnetText(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -}; - -class WifiStaConfigStaticGatewayText : public virtual espgui::TextInterface -{ -public: - WifiStaConfigStaticGatewayText(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -}; - -class WifiStaConfigStaticDns0Text : public virtual espgui::TextInterface -{ -public: - WifiStaConfigStaticDns0Text(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -}; - -class WifiStaConfigStaticDns1Text : public virtual espgui::TextInterface -{ -public: - WifiStaConfigStaticDns1Text(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -}; - -class WifiStaConfigStaticDns2Text : public virtual espgui::TextInterface -{ -public: - WifiStaConfigStaticDns2Text(int index) : m_index{index} {} - - std::string text() const override; - -private: - const int m_index; -};