Skip to content

Commit

Permalink
Flush after debug prints, except SAMD (flush routine too big for SAMD21)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Dec 17, 2024
1 parent 16bc28a commit efe0475
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2711,8 +2711,10 @@ void print_reset_reason(int reason) {
*/
/**************************************************************************/
void printDeviceInfo() {
WS_PRINTER.flush();
WS_DEBUG_PRINTLN("-------Device Information-------");
WS_DEBUG_PRINT("Firmware Version: ");
WS_PRINTER.flush();
WS_DEBUG_PRINTLN(WS_VERSION);
WS_DEBUG_PRINT("Board ID: ");
WS_DEBUG_PRINTLN(BOARD_ID);
Expand Down
38 changes: 35 additions & 3 deletions src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,49 @@

// Define actual debug output functions when necessary.
#ifdef WS_DEBUG
#if defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRWIFI1010)
#define WS_DEBUG_PRINT(...) \
{ WS_PRINTER.print(__VA_ARGS__); } ///< Prints debug output.
{ \
WS_PRINTER.print(__VA_ARGS__); \
yield(); \
} ///< Prints line from debug output.
#define WS_DEBUG_PRINTLN(...) \
{ \
WS_PRINTER.println(__VA_ARGS__); \
yield(); \
} ///< Prints line from debug output.
#define WS_DEBUG_PRINTHEX(...) \
{ \
WS_PRINTER.print(__VA_ARGS__, HEX); \
yield(); \
} ///< Prints debug output.
#else
#define WS_DEBUG_PRINT(...) \
{ \
WS_PRINTER.print(__VA_ARGS__); \
WS_PRINTER.flush(); \
yield(); \
} ///< Prints line from debug output.
#define WS_DEBUG_PRINTLN(...) \
{ WS_PRINTER.println(__VA_ARGS__); } ///< Prints line from debug output.
{ \
WS_PRINTER.println(__VA_ARGS__); \
WS_PRINTER.flush(); \
yield(); \
} ///< Prints line from debug output.
#define WS_DEBUG_PRINTHEX(...) \
{ WS_PRINTER.print(__VA_ARGS__, HEX); } ///< Prints debug output.
{ \
WS_PRINTER.print(__VA_ARGS__, HEX); \
WS_PRINTER.flush(); \
yield(); \
} ///< Prints debug output.
#endif
#else
#define WS_DEBUG_PRINT(...) \
{} ///< Prints debug output
#define WS_DEBUG_PRINTLN(...) \
{} ///< Prints line from debug output.
#define WS_DEBUG_PRINTHEX(...) \
{} ///< Prints debug output.
#endif

#define WS_DELAY_WITH_WDT(timeout) \
Expand Down

0 comments on commit efe0475

Please sign in to comment.