-
Notifications
You must be signed in to change notification settings - Fork 19
Add option for custom rxPin and txPin with HardwareSerial (e.g. for ESP32) #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
sync fork
while keeping existing API for SoftwareSerial
void begin(int baudRate) { | ||
serial.begin(baudRate); | ||
void begin(int baudRate = 9600, uint32_t config = SERIAL_8N1, int pinRx = -1, int pinTx = -1) { | ||
serial.begin(baudRate, config, pinRx, pinTx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esp32 HardwareSerial
is different - and if you try to compile for arduino this would not work
the solution is to put you modified API (with additional params) behind preprocessor directive so it's compiled only in case of esp32
abstractSerial->begin(baudRate); | ||
} | ||
void begin(int baudRate = 9600, uint32_t config = SERIAL_8N1, int pinRx = -1, int pinTx = -1) { | ||
abstractSerial->begin(baudRate, config, pinRx, pinTx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep 2 spaces indentation to be consistent with the rest of the project
ESP32 boards support remapping of GPIO pins to Serial ports (UART0/1/2).
This PR enhances API in Serial.h with an option to pass custom rxPin and txPin to HardwareSerial. It keeps all usage options of the former API (i.e. for using SoftwareSerial), so this change shouldn't break any code created before this PR.