Skip to content

Commit 1541cbc

Browse files
committed
The user can't be bothered with the cumbersome #ifdef logic, rather directly instead the SerialDispatcher within the library and make it available via extern declaration.
1 parent 1be8f61 commit 1541cbc

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/io/serial/SerialDispatcher.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,19 @@ void SerialDispatcher::handleSerialReader()
332332
});
333333
}
334334
}
335+
336+
/**************************************************************************************
337+
* INCLUDE
338+
**************************************************************************************/
339+
340+
#include <Arduino.h>
341+
342+
/**************************************************************************************
343+
* GLOBAL VARIABLE DECLARATION
344+
**************************************************************************************/
345+
346+
#ifdef ARDUINO_PORTENTA_H7_M4
347+
SerialDispatcher Serial(Serial1); /* No SerialUSB for Portenta H7 / M4 Core */
348+
#else
349+
SerialDispatcher Serial(SerialUSB);
350+
#endif

src/io/serial/SerialDispatcher.h

+7
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,11 @@ class SerialDispatcher : public arduino::HardwareSerial
102102
void handleSerialReader();
103103
};
104104

105+
/**************************************************************************************
106+
* EXTERN DECLARATION
107+
**************************************************************************************/
108+
109+
#undef Serial
110+
extern SerialDispatcher Serial;
111+
105112
#endif /* SERIAL_DISPATCHER_H_ */

0 commit comments

Comments
 (0)