Fixed compiling of other configurations

This commit is contained in:
2021-06-28 14:38:03 +02:00
parent 56ebbe8055
commit 27ae2aba21
6 changed files with 28 additions and 20 deletions

View File

@@ -10,6 +10,7 @@
#include "changevaluedisplay.h" #include "changevaluedisplay.h"
#include "displays/updatedisplay.h" #include "displays/updatedisplay.h"
//#include "esputils.h" //#include "esputils.h"
#include "buttons.h"
namespace { namespace {
#ifdef FEATURE_WEBSERVER #ifdef FEATURE_WEBSERVER
@@ -80,7 +81,7 @@ void initWebserver()
if (const auto *textInterface = constCurrentDisplay->asTextInterface()) if (const auto *textInterface = constCurrentDisplay->asTextInterface())
{ {
HtmlTag h2Tag{"h2", response}; HtmlTag h2Tag{"h2", response};
response->print(textInterface->text()); response->print(textInterface->text().c_str());
} }
if (const auto *menuDisplay = constCurrentDisplay->asMenuDisplay()) if (const auto *menuDisplay = constCurrentDisplay->asMenuDisplay())
@@ -97,7 +98,7 @@ void initWebserver()
response->print("><a href=\"/triggerItem?index="); response->print("><a href=\"/triggerItem?index=");
response->print(i); response->print(i);
response->print("\">"); response->print("\">");
response->print(menuItem.text()); response->print(menuItem.text().c_str());
response->print("</a></li>"); response->print("</a></li>");
i++; i++;
@@ -106,7 +107,7 @@ void initWebserver()
else if (const auto *changeValueDisplay = constCurrentDisplay->asChangeValueDisplayInterface()) else if (const auto *changeValueDisplay = constCurrentDisplay->asChangeValueDisplayInterface())
{ {
response->print("<form action=\"/setValue\" method=\"GET\">"); response->print("<form action=\"/setValue\" method=\"GET\">");
response->print("<input type=\"number\" name=\"value\" value=\"" + std::to_string(changeValueDisplay->shownValue()) + "\" />"); response->print(("<input type=\"number\" name=\"value\" value=\"" + std::to_string(changeValueDisplay->shownValue()) + "\" />").c_str());
response->print("<button type=\"submit\">Update</button>"); response->print("<button type=\"submit\">Update</button>");
response->print("</form>"); response->print("</form>");
} }

View File

@@ -67,7 +67,7 @@ void UpdateDisplay::initScreen()
tft.setTextFont(4); tft.setTextFont(4);
tft.setTextColor(TFT_YELLOW); 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); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);

View File

@@ -8,8 +8,8 @@
#include "buttons.h" #include "buttons.h"
namespace { namespace {
namespace dpad5wire namespace dpad5wire {
{ #ifdef FEATURE_DPAD_5WIRESW
class State : public std::array<bool, 8> class State : public std::array<bool, 8>
{ {
public: public:
@@ -95,7 +95,6 @@ State Helper<OUT, IN1, IN2, IN3, IN4>::read()
return result; return result;
} }
#ifdef FEATURE_DPAD_5WIRESW
Helper<PINS_DPAD_5WIRESW_OUT, PINS_DPAD_5WIRESW_IN1, PINS_DPAD_5WIRESW_IN2, PINS_DPAD_5WIRESW_IN3, PINS_DPAD_5WIRESW_IN4> helper; Helper<PINS_DPAD_5WIRESW_OUT, PINS_DPAD_5WIRESW_IN1, PINS_DPAD_5WIRESW_IN2, PINS_DPAD_5WIRESW_IN3, PINS_DPAD_5WIRESW_IN4> helper;
State lastState; State lastState;
millis_t debounceUp, debounceDown, debounceConfirm, debounceBack, debounceProfile0, debounceProfile1, debounceProfile2, debounceProfile3; millis_t debounceUp, debounceDown, debounceConfirm, debounceBack, debounceProfile0, debounceProfile1, debounceProfile2, debounceProfile3;
@@ -170,5 +169,6 @@ void update()
lastState = newState; lastState = newState;
} }
#endif #endif
}
} } // namespace dpad5wire
} // namespace

View File

@@ -5,7 +5,7 @@
#include <HardwareSerial.h> #include <HardwareSerial.h>
#include "bobbycar-protocol/bobbycar-common.h" #include "bobbycar-protocol/bobbycar-serial.h"
#include "types.h" #include "types.h"
@@ -13,13 +13,15 @@ namespace {
class FeedbackParser class FeedbackParser
{ {
public: public:
FeedbackParser(const std::reference_wrapper<HardwareSerial> &serial, bool &feedbackValid, Feedback &feedback) : FeedbackParser(const std::reference_wrapper<HardwareSerial> &serial, bool &feedbackValid, bobbycar::protocol::serial::Feedback &feedback) :
m_serial{serial}, m_feedbackValid{feedbackValid}, m_feedback{feedback} m_serial{serial}, m_feedbackValid{feedbackValid}, m_feedback{feedback}
{ {
} }
void update() void update()
{ {
using namespace bobbycar::protocol::serial;
// Check for new data availability in the Serial buffer // Check for new data availability in the Serial buffer
while (m_serial.get().available()) while (m_serial.get().available())
{ {
@@ -83,6 +85,6 @@ private:
millis_t m_lastFeedback{millis()}; millis_t m_lastFeedback{millis()};
const std::reference_wrapper<HardwareSerial> &m_serial; const std::reference_wrapper<HardwareSerial> &m_serial;
bool &m_feedbackValid; bool &m_feedbackValid;
Feedback &m_feedback, m_newFeedback; bobbycar::protocol::serial::Feedback &m_feedback, m_newFeedback;
}; };
} }

View File

@@ -14,14 +14,13 @@ void initOta()
{ {
ArduinoOTA ArduinoOTA
.onStart([]() { .onStart([]() {
std::to_string type; std::string type;
if (ArduinoOTA.getCommand() == U_FLASH) switch (ArduinoOTA.getCommand())
type = "sketch"; {
else if (ArduinoOTA.getCommand() == U_SPIFFS) // U_SPIFFS case U_FLASH: type = "sketch"; break;
type = "filesystem"; case U_SPIFFS: type = "filesystem"; break;
else default: type = "unknown";
type = "unknown"; }
switchScreenImpl<UpdateDisplay>("Updating " + type); switchScreenImpl<UpdateDisplay>("Updating " + type);
}) })
.onEnd([]() { .onEnd([]() {

View File

@@ -10,7 +10,12 @@
#include <WiFi.h> #include <WiFi.h>
#include <WString.h> #include <WString.h>
#ifdef FEATURE_CAN
#include "bobbycar-protocol/bobbycar-can.h" #include "bobbycar-protocol/bobbycar-can.h"
#endif
#ifdef FEATURE_SERIAL
#include "bobbycar-protocol/bobbycar-serial.h"
#endif
#include "display.h" #include "display.h"
#include "globals.h" #include "globals.h"
@@ -257,6 +262,7 @@ void fixCommonParams()
void sendCommands() void sendCommands()
{ {
#ifdef FEATURE_SERIAL #ifdef FEATURE_SERIAL
using namespace bobbycar::protocol::serial;
for (Controller &controller : controllers) for (Controller &controller : controllers)
{ {
controller.command.start = Command::VALID_HEADER; controller.command.start = Command::VALID_HEADER;