#pragma once #include #ifndef ENABLE_SERIAL_DEBUG #define ENABLE_SERIAL_DEBUG 0 #endif struct Debug { static constexpr bool enabled = static_cast(ENABLE_SERIAL_DEBUG); static inline void begin(unsigned long baud) { if constexpr (enabled) Serial.begin(baud); } template static inline void print(Args&&... args) { if constexpr (enabled) { (Serial.print(std::forward(args)), ...); } } template static inline void println(Args&&... args) { if constexpr (enabled) { (Serial.print(std::forward(args)), ...); Serial.println(); } } template static inline void printf(const char *fmt, Args&&... args) { if constexpr (enabled) { Serial.printf(fmt, std::forward(args)...); } } };