Open matthewmcneill opened 1 month ago
Alternatively a more future-proof way is to change the declaration of the global variable at the bottom of the .cpp only to create it if these are properly defined - forcing the user to manually declare RS458 with their own configs.
RS485Class RS485(RS485_SERIAL_PORT, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN); #elif SERIAL_PORT_HARDWARE RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
This is relatively simple, just need to add the correct architecture pins for the Hardware Serial1 to the architectures in RS432.h
I'm not sure you want the default TX pin to be 1 however, so you may need to change that too.
elif defined(ARDUINO_ARCH_ESP32)
define SERIAL_PORT_HARDWARE Serial1
define RS485_DEFAULT_DE_PIN 8
define RS485_DEFAULT_RE_PIN 7
define RS485_DEFAULT_TX_PIN 2
Without this change the library complains about the SERIAL_PORT_HARDWARE macro not being defined upon compilation