corridor_control/fan_control/include/serial.hpp

31 lines
742 B
C++
Raw Normal View History

2021-06-28 10:36:43 +02:00
#include <Arduino.h>
#include <list>
2021-06-28 10:36:43 +02:00
2021-07-01 22:46:32 +02:00
class WsSerial{
std::list<String> debug;
2021-07-01 22:46:32 +02:00
public:
2021-07-03 19:49:43 +02:00
inline void println(const String& line){
// enable debug the debugging
Serial.println(line.c_str());
if(debug.size() > 100 ) debug.pop_back();
debug.push_front(line);
2021-07-03 19:49:43 +02:00
}
2021-07-01 22:46:32 +02:00
inline void println(const float num){ println(String(num)) ; };
2021-07-03 19:49:43 +02:00
inline const String& first(){ return debug.front();};
inline void pop(){ return debug.pop_front();};
2021-07-01 22:46:32 +02:00
inline bool empty(){ return debug.empty();};
inline void clear(){ debug.clear();}
2021-07-01 22:46:32 +02:00
};
2021-07-03 19:49:43 +02:00
extern WsSerial debug_out;
2021-07-01 22:46:32 +02:00
#if(false)
2021-06-28 10:36:43 +02:00
#define DEBUG_OUT Serial
2021-07-01 22:46:32 +02:00
#define DEBUG_SERIAL true
#else
#define DEBUG_SERIAL false
#define DEBUG_OUT debug_out
#endif