|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#ifdef DEBUG_LOGS_PREFIX |
| 4 | +#include <Arduino.h> |
| 5 | + |
| 6 | +#pragma region // Logging without a prefix. |
| 7 | +/** @brief Simply logs whatever is passed. */ |
| 8 | +#define DEBUG_PRINT_NOPRE_NOPM(...) \ |
| 9 | +Serial.print(__VA_ARGS__) |
| 10 | + |
| 11 | +/** @brief Logs whatever is passed, storing the input into flash memory using `F()`. */ |
| 12 | +#define DEBUG_PRINT_NOPRE(string) \ |
| 13 | +Serial.print(F(string)) |
| 14 | + |
| 15 | +/** @brief Logs whatever is passed, with a new-line at the end. */ |
| 16 | +#define DEBUG_PRINT_NOPRE_LN_NOPM(...) \ |
| 17 | +Serial.println(__VA_ARGS__) |
| 18 | + |
| 19 | +/** @brief Logs whatever is passed, with a new-line at the end, storing the input into flash memory using `F()`. */ |
| 20 | +#define DEBUG_PRINT_NOPRE_LN(string) \ |
| 21 | +Serial.println(F(string)) |
| 22 | +#pragma endregion |
| 23 | + |
| 24 | +#pragma region // Logging with a prefix. |
| 25 | +/** @brief Logs with the prefix, and a new-line at the end, storing the input into flash memory using `F()`. */ |
| 26 | +#define DEBUG_PRINT_LN(string) \ |
| 27 | + Serial.print(F(DEBUG_LOGS_PREFIX)); \ |
| 28 | + Serial.println(F(string)) |
| 29 | + |
| 30 | +/** @brief Simply logs whatever is passed with the prefix. */ |
| 31 | +#define DEBUG_PRINT_NOPM(...) \ |
| 32 | + Serial.print(DEBUG_LOGS_PREFIX); \ |
| 33 | + Serial.print(__VA_ARGS__) |
| 34 | + |
| 35 | +/** @brief Logs with the prefix, storing the input into flash memory using `F()`. */ |
| 36 | +#define DEBUG_PRINT(string) \ |
| 37 | + Serial.print(F(DEBUG_LOGS_PREFIX)); \ |
| 38 | + Serial.print(F(string)) |
| 39 | + |
| 40 | +/** @brief Logs with the prefix, and a new-line at the end. */ |
| 41 | +#define DEBUG_PRINT_LN_NOPM(...) \ |
| 42 | + Serial.print(F(DEBUG_LOGS_PREFIX)); \ |
| 43 | + Serial.println(__VA_ARGS__) |
| 44 | +#pragma endregion |
| 45 | + |
| 46 | +#else // Else, we define these as empty: |
| 47 | + |
| 48 | +// Without a prefix: |
| 49 | +#define DEBUG_PRINT_NOPRE_NOPM(...) |
| 50 | +#define DEBUG_PRINT_NOPRE(string) |
| 51 | +#define DEBUG_PRINT_NOPRE_LN_NOPM(...) |
| 52 | +#define DEBUG_PRINT_NOPRE_LN(string) |
| 53 | + |
| 54 | +// With a prefix: |
| 55 | +#define DEBUG_PRINT_NOPM(...) |
| 56 | +#define DEBUG_PRINT(string) |
| 57 | +#define DEBUG_PRINT_LN_NOPM(...) |
| 58 | +#define DEBUG_PRINT_LN(string) |
| 59 | + |
| 60 | +#endif |
0 commit comments