Skip to content

Commit 71fc7f3

Browse files
committed
Using overloads instead of default arguments removes ambiguity from begin() syntax.
1 parent a3cb35e commit 71fc7f3

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/SoftwareSerial.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ void SoftwareSerial::begin(uint32_t baud, SoftwareSerialConfig config,
100100
if (!m_rxEnabled) { enableRx(true); }
101101
}
102102

103-
void SoftwareSerial::begin(uint32_t baud, SoftwareSerialConfig config) {
104-
begin(baud, config, -1, -1, m_invert);
105-
}
106-
107103
void SoftwareSerial::end()
108104
{
109105
enableRx(false);

src/SoftwareSerial.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,20 @@ class SoftwareSerial : public Stream {
106106
/// bit receive buffer, a suggested size is bufCapacity times the sum of
107107
/// start, data, parity and stop bit count.
108108
void begin(uint32_t baud, SoftwareSerialConfig config,
109-
int8_t rxPin, int8_t txPin = -1,
110-
bool invert = false, int bufCapacity = 64, int isrBufCapacity = 0);
111-
void begin(uint32_t baud, SoftwareSerialConfig config = SWSERIAL_8N1);
109+
int8_t rxPin, int8_t txPin, bool invert,
110+
int bufCapacity = 64, int isrBufCapacity = 0);
111+
void begin(uint32_t baud, SoftwareSerialConfig config,
112+
int8_t rxPin, int8_t txPin) {
113+
begin(baud, config, rxPin, txPin, m_invert);
114+
}
115+
void begin(uint32_t baud, SoftwareSerialConfig config,
116+
int8_t rxPin) {
117+
begin(baud, config, rxPin, m_txPin, m_invert);
118+
}
119+
void begin(uint32_t baud, SoftwareSerialConfig config = SWSERIAL_8N1) {
120+
begin(baud, config, m_rxPin, m_txPin, m_invert);
121+
}
122+
112123
uint32_t baudRate();
113124
/// Transmit control pin.
114125
void setTransmitEnablePin(int8_t txEnablePin);

0 commit comments

Comments
 (0)