FastLED 3.9.3
Loading...
Searching...
No Matches
file_system.cpp
1#include "file_system.h"
2
3
4#ifdef __EMSCRIPTEN__
5#include "platforms/wasm/fs_wasm.h"
6#elif __has_include(<SD.h>)
7// work in progress.
8//#include "platforms/fs_sdcard_arduino.hpp"
9#endif
10
11#include "namespace.h"
12
13
14FASTLED_NAMESPACE_BEGIN
15
16// WEAK SYMBOL
17// Override this if you want to supply a file system for your platform.
18__attribute__((weak)) FsImplRef make_sdcard_filesystem(int cs_pin) {
19 return FsImplRef::Null();
20}
21
22bool FileSystem::beginSd(int cs_pin) {
23 mFs = make_sdcard_filesystem(cs_pin);
24 if (!mFs) {
25 return false;
26 }
27 mFs->begin();
28 return true;
29}
30
31bool FileSystem::begin(FsImplRef platform_filesystem) {
32 mFs = platform_filesystem;
33 if (!mFs) {
34 return false;
35 }
36 mFs->begin();
37 return true;
38}
39
40size_t FileHandle::bytesLeft() const { return size() - pos(); }
41
42FileSystem::FileSystem() : mFs() {}
43
44
45void FileSystem::end() {
46 if (mFs) {
47 mFs->end();
48 }
49}
50
51void FileSystem::close(FileHandleRef file) { mFs->close(file); }
52
53FileHandleRef FileSystem::openRead(const char *path) { return mFs->openRead(path); }
54Video FileSystem::openVideo(const char *path, size_t pixelsPerFrame, float fps, size_t nFrameHistory) {
55 Video video;
56 FileHandleRef file = openRead(path);
57 if (!file) {
58 return video;
59 }
60 video.begin(file, pixelsPerFrame, fps, nFrameHistory);
61 return video;
62}
63
64FASTLED_NAMESPACE_END
Definition video.h:23