diff --git a/terminal_disp.cpp b/terminal_disp.cpp new file mode 100644 index 0000000..0fe71e6 --- /dev/null +++ b/terminal_disp.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "disp.h" +#include "terminal_disp.h" + +void terminal_disp::status(const char *s) { + _p.println(s); +} + +void terminal_disp::write(uint8_t b) { + char c = (char)b; + switch(c) { + case '_': + _p.write(' '); + _p.write('\b'); + _p.write('\b'); + _p.write('_'); + _p.write('\b'); + break; + case '\r': + _p.write(' '); + _p.write('\r'); + _p.write('\n'); + break; + default: + _p.write(b); + break; + } + _p.write('_'); + _p.write('\b'); +} diff --git a/terminal_disp.h b/terminal_disp.h new file mode 100644 index 0000000..080b0af --- /dev/null +++ b/terminal_disp.h @@ -0,0 +1,17 @@ +#ifndef __TERMINAL_DISP_H__ +#define __TERMINAL_DISP_H__ + +class terminal_disp: public disp { +public: + terminal_disp(Print &p): _p(p) {} + + void checkpoint(Stream &) {} + void restore(Stream &) {} + void status(const char *); + void write(uint8_t); + +private: + Print &_p; +}; + +#endif