-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support Serial1 on ESP32 #7
Comments
If I remember correctly there was an problem with In any case, maybe I can do something better now. void SerialPM::init(uint8_t rx=0, uint8_t tx=0) {
if (hwSerial) {
if (rx & tx) {
static_cast<HardwareSerial *>(uart)->begin(9600, SERIAL_8N1, rx, tx);
} else {
static_cast<HardwareSerial *>(uart)->begin(9600, SERIAL_8N1);
} I know I took very long to answer, but still need think to think about it. |
I won't enable SoftwareSerial on the ESP32, so could use the #ifdef HAS_SW_SERIAL
SerialPM(PMS sensor, uint8_t rx, uint8_t tx) : pms(sensor)
{
SoftwareSerial serial(rx, tx);
uart = &serial;
hwSerial = false;
}
#elif defined(ESP32)
SerialPM(PMS sensor, uint8_t rx, uint8_t tx) : pms(sensor), rx(rx), tx(tx)
{
uart = &Serial1;
hwSerial = true;
}
#endif |
It's okay as a workaround. |
I see your point. However, it is "standard practice" to hide the On a library I prefer the "tell me what you want" approach over the "tell me how to do it". |
As with UART, i2c pins can be remapped... |
Hi, thank you for the great library.
I would like to use it with ESP32 HW Serial1 on custom pins (HW serial could be remapped to almost any pins on this MC) however, the library reinitializes serial interface during the init.
I can fix code in the library, but it isn't a good way.
As for me, the library shouldn't reconfigure the interface, just use it, though probably this code was added to simplify usage.
Any thoughts about some kind of workaround?
The text was updated successfully, but these errors were encountered: