diff --git a/acia.h b/acia.h index 96f7def..960824e 100644 --- a/acia.h +++ b/acia.h @@ -9,6 +9,7 @@ public: uint8_t read(Memory::address); ACIA(serialio &s): _serial(&s) {} + void set_device(serialio *s) { _serial = s; } // status bits // @@ -55,6 +56,6 @@ protected: virtual void write_data(uint8_t); private: - class serialio *_serial; + serialio *_serial; }; #endif diff --git a/flash_filer.cpp b/flash_filer.cpp index d93d328..f4fdbd2 100644 --- a/flash_filer.cpp +++ b/flash_filer.cpp @@ -29,6 +29,38 @@ bool flash_file::seek(uint32_t pos) #endif } +bool flash_file::more() +{ +#if defined(USE_SPIFFS) || defined(USE_LITTLEFS) + return files[_fd].available() > 0; +#else + return false; +#endif +} + +uint8_t flash_file::read() { +#if defined(USE_SPIFFS) || defined(USE_LITTLEFS) + return files[_fd].read(); +#else + return 0xff; +#endif +} + +flash_file::operator bool() const { +#if defined(USE_SPIFFS) || defined(USE_LITTLEFS) + return files[_fd]; +#else + return false; +#endif +} + +void flash_file::write(uint8_t b) { +#if defined(USE_SPIFFS) || defined(USE_LITTLEFS) + files[_fd].write(b); + files[_fd].flush(); +#endif +} + bool flash_filer::start() { #if defined(USE_LITTLEFS) @@ -50,30 +82,6 @@ void flash_filer::stop() #endif } -bool flash_file::more() -{ -#if defined(USE_SPIFFS) || defined(USE_LITTLEFS) - return files[_fd].available() > 0; -#else - return false; -#endif -} - -uint8_t flash_file::read() { -#if defined(USE_SPIFFS) || defined(USE_LITTLEFS) - return files[_fd].read(); -#else - return 0xff; -#endif -} - -void flash_file::write(uint8_t b) { -#if defined(USE_SPIFFS) || defined(USE_LITTLEFS) - files[_fd].write(b); - files[_fd].flush(); -#endif -} - const char *flash_filer::advance() { #if defined(USE_SPIFFS) || defined(USE_LITTLEFS) bool rewound = false; diff --git a/flash_filer.h b/flash_filer.h index 8af42e7..97b9bcc 100644 --- a/flash_filer.h +++ b/flash_filer.h @@ -1,7 +1,7 @@ #ifndef __FLASH_FILER_H__ #define __FLASH_FILER_H__ -#define MAX_FILES 3 +#define MAX_FILES 5 class flash_file: virtual public serialio { public: @@ -12,6 +12,7 @@ public: virtual void write(uint8_t); bool seek(uint32_t pos); + operator bool() const; private: const uint8_t _fd;