Files
smart-rgb-esp32/include/debugutil.hpp

30 lines
923 B
C++
Raw Normal View History

2025-08-29 11:46:17 +02:00
#pragma once
#include <Arduino.h>
#ifndef ENABLE_SERIAL_DEBUG
#define ENABLE_SERIAL_DEBUG 0
#endif
struct Debug {
static constexpr bool enabled = static_cast<bool>(ENABLE_SERIAL_DEBUG);
static inline void begin(unsigned long baud) {
if constexpr (enabled) Serial.begin(baud);
}
template<typename... Args>
static inline void print(Args&&... args) {
if constexpr (enabled) { (Serial.print(std::forward<Args>(args)), ...); }
}
template<typename... Args>
static inline void println(Args&&... args) {
if constexpr (enabled) {
(Serial.print(std::forward<Args>(args)), ...);
Serial.println();
}
}
template<typename... Args>
static inline void printf(const char *fmt, Args&&... args) {
if constexpr (enabled) {
Serial.printf(fmt, std::forward<Args>(args)...);
}
}
};