From 06f385b6cdd20de6df8df0d1718d43092bfd22ae Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Tue, 12 Feb 2019 18:19:09 +0000 Subject: [PATCH] serial filer --- r65emu.h | 1 + serial_filer.cpp | 30 ++++++++++++++++++++++++++++++ serial_filer.h | 19 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 serial_filer.cpp create mode 100644 serial_filer.h diff --git a/r65emu.h b/r65emu.h index 0113082..5c641df 100644 --- a/r65emu.h +++ b/r65emu.h @@ -11,6 +11,7 @@ #include "keyboard.h" #include "serialio.h" #include "filer.h" +#include "serial_filer.h" #include "timed.h" #include "hardware.h" #include "sound_dac.h" diff --git a/serial_filer.cpp b/serial_filer.cpp new file mode 100644 index 0000000..56fee79 --- /dev/null +++ b/serial_filer.cpp @@ -0,0 +1,30 @@ +#include +#include +#include "hardware.h" +#include "serialio.h" +#include "filer.h" +#include "serial_filer.h" + +bool serial_filer::start(const char *) { + Serial.begin(TERM_SPEED); + return true; +} + +void serial_filer::write(uint8_t b) { + Serial.write(b); +} + +uint8_t serial_filer::read() { + return Serial.read(); +} + +bool serial_filer::more() { + return Serial.available() > 0; +} + +const char *serial_filer::checkpoint() { + return 0; +} + +void serial_filer::restore(const char *) { +} diff --git a/serial_filer.h b/serial_filer.h new file mode 100644 index 0000000..36a5e29 --- /dev/null +++ b/serial_filer.h @@ -0,0 +1,19 @@ +#ifndef __SERIAL_FILER_H__ +#define __SERIAL_FILER_H__ + +class serial_filer: public filer { +public: + const char *advance() { return "serial"; } + const char *rewind() { return advance(); } + + const char *checkpoint(); + void restore(const char *); + + bool start(const char *); + void stop() {} + + uint8_t read(); + bool more(); + void write(uint8_t); +}; +#endif