From 930b9e23ab981251e0cbd839c5a2f3a769c3fb47 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 31 Jul 2015 20:34:29 +0200 Subject: o Even better Debug for the ATtiny85 implementation.h. --- Debug.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Debug.h') diff --git a/Debug.h b/Debug.h index 2de911b..83eb43f 100644 --- a/Debug.h +++ b/Debug.h @@ -3,6 +3,22 @@ #include "config-check.h" +#ifdef __AVR_ATtiny85__ +class Serial { +public: + void begin(int); + void write(uint8_t); + int read(); + void print(...); + void println(...); + operator bool(); + bool available(); + void flush(); +}; + +extern Serial Serial; +#endif + enum DebugSink { DEBUG_SINK_SERIAL, DEBUG_SINK_SOFTWARE_SERIAL, @@ -30,6 +46,14 @@ public: return false; }; + inline int read() const { + if (sink == DEBUG_SINK_SERIAL) { + return Serial.read(); + } + + return '\0'; + }; + size_t write(uint8_t value) const { if (sink == DEBUG_SINK_SERIAL) { Serial.write(value); -- cgit v1.2.3