From 9137e7dd3d88591694d7de9d69872907d1d44b8b Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Wed, 22 Mar 2023 14:16:31 +0100 Subject: [PATCH] Allow different Serial-port to be used on ESP32 --- ESP32/console_esp32.cpp | 13 +++++++------ ESP32/console_esp32.h | 5 ++++- ESP32/main.ino | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ESP32/console_esp32.cpp b/ESP32/console_esp32.cpp index 73e7d64..2e73c8a 100644 --- a/ESP32/console_esp32.cpp +++ b/ESP32/console_esp32.cpp @@ -10,8 +10,9 @@ #define NEOPIXELS_PIN 25 -console_esp32::console_esp32(std::atomic_uint32_t *const stop_event, bus *const b) : - console(stop_event, b) +console_esp32::console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, Stream & io_port) : + console(stop_event, b), + io_port(io_port) { } @@ -23,8 +24,8 @@ console_esp32::~console_esp32() int console_esp32::wait_for_char_ll(const short timeout) { for(short i=0; igetCpu(); diff --git a/ESP32/console_esp32.h b/ESP32/console_esp32.h index 6197fa3..4590ddf 100644 --- a/ESP32/console_esp32.h +++ b/ESP32/console_esp32.h @@ -5,13 +5,16 @@ class console_esp32 : public console { +private: + Stream & io_port; + protected: int wait_for_char_ll(const short timeout) override; void put_char_ll(const char c) override; public: - console_esp32(std::atomic_uint32_t *const stop_event, bus *const b); + console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, Stream & io_port); virtual ~console_esp32(); void put_string_lf(const std::string & what) override; diff --git a/ESP32/main.ino b/ESP32/main.ino index cf8f4fb..a2014b9 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -317,7 +317,7 @@ void setup() { b->add_cpu(c); Serial.println(F("Init console")); - cnsl = new console_esp32(&stop_event, b); + cnsl = new console_esp32(&stop_event, b, Serial); Serial.println(F("Start line-frequency interrupt")); kw11_l *lf = new kw11_l(b, cnsl);