From d967d8efd92cab63b1c9e8850d6e301c91bc7d8a Mon Sep 17 00:00:00 2001 From: Magnus Persson Date: Wed, 19 Oct 2022 19:52:55 +0200 Subject: [PATCH] Update serial console --- platformio.ini | 6 +++--- src/helper.cpp | 17 +++++++++++++++++ src/main.hpp | 6 +++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 877989c..08bb803 100644 --- a/platformio.ini +++ b/platformio.ini @@ -148,7 +148,7 @@ build_flags = -DCORE_DEBUG_LEVEL=0 -DESP32C3 -DARDUINO_ESP32C3_DEV - -DUSE_SERIAL0 + -DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port lib_deps = ${common_env_data.lib_deps} ${common_env_data.lib_deps32} @@ -181,7 +181,7 @@ build_flags = -DCORE_DEBUG_LEVEL=0 -DESP32S2 -DARDUINO_ESP32S2_DEV - -DUSE_SERIAL0 + -DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port lib_deps = ${common_env_data.lib_deps} lib_ignore = @@ -226,7 +226,7 @@ build_flags = -DCORE_DEBUG_LEVEL=5 -DJTAG_DEBUG -DESP32C3 - -DUSE_SERIAL0 + -DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port -DARDUINO_ESP32C3_DEV -DCOLLECT_PERFDATA # Collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb lib_deps = diff --git a/src/helper.cpp b/src/helper.cpp index 12acba4..efdf2a2 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -237,7 +237,24 @@ void printBuildOptions() { SerialDebug::SerialDebug(const uint32_t serialSpeed) { // Start serial with auto-detected rate (default to defined BAUD) +#if defined(USE_SERIAL_PINS) && defined(ESP8266) EspSerial.begin(serialSpeed); +#elif defined(ESP8266) + EspSerial.begin(serialSpeed, SERIAL_8N1, 3, 1); +#elif defined(USE_SERIAL_PINS) && defined(ESP32C3) + EspSerial.begin(115200L, SERIAL_8N1, 20, 21); +#elif defined(ESP32C3) + EspSerial.begin(115200L); +#elif defined(USE_SERIAL_PINS) && defined(ESP32S2) + EspSerial.begin(115200L, SERIAL_8N1, 37, 39); +#elif defined(ESP32S2) + EspSerial.begin(115200L); +#elif defined(USE_SERIAL_PINS) && defined(ESP32) + EspSerial.begin(serialSpeed, SERIAL_8N1, 3, 1); +#elif defined(ESP32) + EspSerial.begin(115200L); +#endif + EspSerial.println("Serial connection established"); getLog()->begin(LOG_LEVEL, &EspSerial, true); getLog()->setPrefix(printTimestamp); diff --git a/src/main.hpp b/src/main.hpp index 87bd57b..646fbff 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -91,9 +91,9 @@ extern RunMode runMode; // #define PIN_A0 A4 #endif -#if defined(ESP32C3) && defined(USE_SERIAL0) -#define EspSerial Serial0 -// #warning "Using Serial0 for output RX/TX pins on ESP32C3" +#if defined(USE_SERIAL_PINS) && defined(ESP32) +// #define EspSerial Serial0 // We cant use Serial on newer boards since this is using USBC port +#define EspSerial Serial0 // We cant use Serial on newer boards since this is using USBC port #else #define EspSerial Serial #endif