7#include "platforms/is_platform.h"
15#if !defined(FL_IS_TEENSY) && FL_HAS_INCLUDE(<SD.h>) && FL_HAS_INCLUDE(<fs.h>) && \
16 FL_HAS_INCLUDE(<SPI.h>)
44class SdFatFileHandle :
public filebuf {
50 SdFatFileHandle(SdFile file,
const char* path) : _file(fl::
move(file)), _path(path) {}
58 return _file.isOpen();
61 auto f =
const_cast<SdFatFileHandle*
>(
this);
62 return f->_file.available() > 0;
65 return _file.fileSize();
68 return _file.read(
reinterpret_cast<u8*
>(dst), bytesToRead);
72 (void)data; (void)count;
76 return _file.curPosition();
84 return _file.seekEnd(
pos);
93 auto f =
const_cast<SdFatFileHandle*
>(
this);
94 return f->_file.available() <= 0;
96 bool has_error()
const override {
return false; }
97 void clear_error()
override {}
98 int error_code()
const override {
return 0; }
99 const char* error_message()
const override {
return "No error"; }
102class SDFileHandle :
public filebuf {
108 SDFileHandle(File file,
const char* path) : _file(file), _path(path) {}
116 auto f =
const_cast<File&
>(_file);
120 auto f =
const_cast<File&
>(_file);
121 return f.available() > 0;
124 auto f =
const_cast<File&
>(_file);
128 return _file.read(
reinterpret_cast<u8*
>(dst), bytesToRead);
132 (void)data; (void)count;
136 auto f =
const_cast<File&
>(_file);
140 return _path.c_str();
146 auto f =
const_cast<File&
>(_file);
147 return _file.seek(f.position() +
pos);
149 auto f =
const_cast<File&
>(_file);
150 return _file.seek(f.size() +
pos);
159 auto f =
const_cast<File&
>(_file);
160 return f.available() <= 0;
162 bool has_error()
const override {
return false; }
163 void clear_error()
override {}
164 int error_code()
const override {
return 0; }
165 const char* error_message()
const override {
return "No error"; }
169class FsArduino :
public FsImpl {
177 FsArduino(
int cs_pin) : _cs_pin(cs_pin) {}
182 return _sd.begin(_cs_pin, SPI_HALF_SPEED);
184 return SD.begin(_cs_pin);
197 if (!file.open(name, O_READ)) {
202 File file = SD.open(name, FILE_READ);
219#define FASTLED_HAS_SDCARD_ARDUINO_IMPL 1
A mounted storage medium.
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
fl::shared_ptr< filebuf > filebuf_ptr
InputGamut g FL_NO_EXCEPT
constexpr T * end(T(&array)[N]) FL_NO_EXCEPT
FsImplPtr make_sdcard_filesystem(int cs_pin)
constexpr T * begin(T(&array)[N]) FL_NO_EXCEPT
Base definition for an LED controller.
#define FASTLED_SHARED_PTR(type)