From c0886ebea33520afafda400e0532c09162737b12 Mon Sep 17 00:00:00 2001 From: Pontus Oldberg Date: Wed, 10 Jul 2024 14:50:33 +0200 Subject: [PATCH] Added a reset pin option for the OLED driver and cleaned up a bit. --- CommandStation-EX.ino | 3 --- SSD1306Ascii.cpp | 9 ++++++++- WifiInterface.cpp | 5 +++++ config.example.h | 3 +++ defines.h | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 2e749a7..6b0ea71 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -72,9 +72,6 @@ void setup() pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - while(!Serial) - delay(100); - // Responsibility 1: Start the usb connection for diagnostics // This is normally Serial but uses SerialUSB on a SAMD processor SerialManager::init(); diff --git a/SSD1306Ascii.cpp b/SSD1306Ascii.cpp index ea0c76b..3ada0c3 100644 --- a/SSD1306Ascii.cpp +++ b/SSD1306Ascii.cpp @@ -159,7 +159,14 @@ SSD1306AsciiWire::SSD1306AsciiWire(I2CAddress address, int width, int height) { bool SSD1306AsciiWire::begin() { I2CManager.begin(); - I2CManager.setClock(400000L); // Set max supported I2C speede + I2CManager.setClock(400000L); // Set max supported I2C speed + +#if defined(OLED_HAS_RESET_PIN) + pinMode(OLED_HAS_RESET_PIN, OUTPUT); + digitalWrite(OLED_HAS_RESET_PIN, LOW); + delay(1); + digitalWrite(OLED_HAS_RESET_PIN, HIGH); +#endif if (m_i2cAddr == 0) { // Probe for I2C device on 0x3c and 0x3d. diff --git a/WifiInterface.cpp b/WifiInterface.cpp index 8b2251a..cf95cd8 100644 --- a/WifiInterface.cpp +++ b/WifiInterface.cpp @@ -76,6 +76,11 @@ Stream * WifiInterface::wifiStream; #endif #endif +#if defined(ARDUINO_ARCH_RP2040) +#define NUM_SERIAL 2 +#define SERIAL1 Serial2 +#endif + #ifndef NUM_SERIAL #define NUM_SERIAL 1 #define SERIAL1 Serial1 diff --git a/config.example.h b/config.example.h index 0f136f9..11d7fe3 100644 --- a/config.example.h +++ b/config.example.h @@ -160,6 +160,9 @@ The configuration file for DCC-EX Command Station // 128x32 or 128x64 I2C SSD1306-based devices are supported. // Use 132,64 for a SH1106-based I2C device with a 128x64 display. // #define OLED_DRIVER 0x3c,128,32 +// Some OLED displays have an external reset pin that needs to be managed. Set the following +// macro to point to that pin. +// #define OLED_HAS_RESET_PIN 5 // Define scroll mode as 0, 1 or 2 // * #define SCROLLMODE 0 is scroll continuous (fill screen if poss), diff --git a/defines.h b/defines.h index 469c63f..7a33bbb 100644 --- a/defines.h +++ b/defines.h @@ -208,6 +208,7 @@ // Currently only devices which can communicate at 115200 are supported. // #define WIFI_SERIAL_LINK_SPEED 115200 +#define WIFI_SERIAL_PORT Serial2 #if __has_include ( "myAutomation.h") #if defined(HAS_ENOUGH_MEMORY) || defined(DISABLE_EEPROM) || defined(DISABLE_PROG)