From 27ae2aba21202a2d9f687b694463bc3650b73234 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Mon, 28 Jun 2021 14:38:03 +0200 Subject: [PATCH] Fixed compiling of other configurations --- src/bobby_webserver.h | 7 ++++--- src/displays/updatedisplay.h | 2 +- src/dpad5wire.h | 10 +++++----- src/feedbackparser.h | 8 +++++--- src/ota.h | 15 +++++++-------- src/utils.h | 6 ++++++ 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/bobby_webserver.h b/src/bobby_webserver.h index ee66769..b3aba7c 100644 --- a/src/bobby_webserver.h +++ b/src/bobby_webserver.h @@ -10,6 +10,7 @@ #include "changevaluedisplay.h" #include "displays/updatedisplay.h" //#include "esputils.h" +#include "buttons.h" namespace { #ifdef FEATURE_WEBSERVER @@ -80,7 +81,7 @@ void initWebserver() if (const auto *textInterface = constCurrentDisplay->asTextInterface()) { HtmlTag h2Tag{"h2", response}; - response->print(textInterface->text()); + response->print(textInterface->text().c_str()); } if (const auto *menuDisplay = constCurrentDisplay->asMenuDisplay()) @@ -97,7 +98,7 @@ void initWebserver() response->print(">print(i); response->print("\">"); - response->print(menuItem.text()); + response->print(menuItem.text().c_str()); response->print(""); i++; @@ -106,7 +107,7 @@ void initWebserver() else if (const auto *changeValueDisplay = constCurrentDisplay->asChangeValueDisplayInterface()) { response->print("
"); - response->print("shownValue()) + "\" />"); + response->print(("shownValue()) + "\" />").c_str()); response->print(""); response->print("
"); } diff --git a/src/displays/updatedisplay.h b/src/displays/updatedisplay.h index f220a77..f205043 100644 --- a/src/displays/updatedisplay.h +++ b/src/displays/updatedisplay.h @@ -67,7 +67,7 @@ void UpdateDisplay::initScreen() tft.setTextFont(4); tft.setTextColor(TFT_YELLOW); - tft.drawString(m_title, 5, 5, 4); + tft.drawString(m_title.c_str(), 5, 5, 4); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); diff --git a/src/dpad5wire.h b/src/dpad5wire.h index 73f61b0..908e006 100644 --- a/src/dpad5wire.h +++ b/src/dpad5wire.h @@ -8,8 +8,8 @@ #include "buttons.h" namespace { -namespace dpad5wire -{ +namespace dpad5wire { +#ifdef FEATURE_DPAD_5WIRESW class State : public std::array { public: @@ -95,7 +95,6 @@ State Helper::read() return result; } -#ifdef FEATURE_DPAD_5WIRESW Helper helper; State lastState; millis_t debounceUp, debounceDown, debounceConfirm, debounceBack, debounceProfile0, debounceProfile1, debounceProfile2, debounceProfile3; @@ -170,5 +169,6 @@ void update() lastState = newState; } #endif -} -} + +} // namespace dpad5wire +} // namespace diff --git a/src/feedbackparser.h b/src/feedbackparser.h index afd4603..9b31130 100644 --- a/src/feedbackparser.h +++ b/src/feedbackparser.h @@ -5,7 +5,7 @@ #include -#include "bobbycar-protocol/bobbycar-common.h" +#include "bobbycar-protocol/bobbycar-serial.h" #include "types.h" @@ -13,13 +13,15 @@ namespace { class FeedbackParser { public: - FeedbackParser(const std::reference_wrapper &serial, bool &feedbackValid, Feedback &feedback) : + FeedbackParser(const std::reference_wrapper &serial, bool &feedbackValid, bobbycar::protocol::serial::Feedback &feedback) : m_serial{serial}, m_feedbackValid{feedbackValid}, m_feedback{feedback} { } void update() { + using namespace bobbycar::protocol::serial; + // Check for new data availability in the Serial buffer while (m_serial.get().available()) { @@ -83,6 +85,6 @@ private: millis_t m_lastFeedback{millis()}; const std::reference_wrapper &m_serial; bool &m_feedbackValid; - Feedback &m_feedback, m_newFeedback; + bobbycar::protocol::serial::Feedback &m_feedback, m_newFeedback; }; } diff --git a/src/ota.h b/src/ota.h index 17c7331..65712e2 100644 --- a/src/ota.h +++ b/src/ota.h @@ -14,14 +14,13 @@ void initOta() { ArduinoOTA .onStart([]() { - std::to_string type; - if (ArduinoOTA.getCommand() == U_FLASH) - type = "sketch"; - else if (ArduinoOTA.getCommand() == U_SPIFFS) // U_SPIFFS - type = "filesystem"; - else - type = "unknown"; - + std::string type; + switch (ArduinoOTA.getCommand()) + { + case U_FLASH: type = "sketch"; break; + case U_SPIFFS: type = "filesystem"; break; + default: type = "unknown"; + } switchScreenImpl("Updating " + type); }) .onEnd([]() { diff --git a/src/utils.h b/src/utils.h index e2d282f..fe8184f 100644 --- a/src/utils.h +++ b/src/utils.h @@ -10,7 +10,12 @@ #include #include +#ifdef FEATURE_CAN #include "bobbycar-protocol/bobbycar-can.h" +#endif +#ifdef FEATURE_SERIAL +#include "bobbycar-protocol/bobbycar-serial.h" +#endif #include "display.h" #include "globals.h" @@ -257,6 +262,7 @@ void fixCommonParams() void sendCommands() { #ifdef FEATURE_SERIAL + using namespace bobbycar::protocol::serial; for (Controller &controller : controllers) { controller.command.start = Command::VALID_HEADER;