FastLED 3.9.3
Loading...
Searching...
No Matches
filebuffer.h
1
2#pragma once
3
4#include <stdint.h>
5
6#include "file_system.h"
7#include "ref.h"
8#include "crgb.h"
9#include "namespace.h"
10
11FASTLED_NAMESPACE_BEGIN
12
13FASTLED_SMART_REF(FileBuffer);
14FASTLED_SMART_REF(FileHandle);
15
16class FileBuffer: public Referent {
17 public:
18 FileBuffer(FileHandleRef file);
19 virtual ~FileBuffer();
20 void rewindToStart();
21 bool available() const;
22 int32_t BytesLeft() const;
23 int32_t FileSize() const;
24
25 // Reads the next byte, else -1 is returned for end of buffer.
26 int16_t read();
27 size_t read(uint8_t* dst, size_t n);
28 size_t read(CRGB* dst, size_t n) { return read((uint8_t*)dst, n * 3); }
29
30 private:
31 void ResetBuffer();
32 void RefillBufferIfNecessary();
33 void RefillBuffer();
34
35 // Experimentally found to be as fast as larger values.
36 static const int kBufferSize = 64;
37 uint8_t mBuffer[kBufferSize];
38 int16_t mCurrIdx;
39 int16_t mLength;
40
41 FileHandleRef mFile;
42};
43
44FASTLED_NAMESPACE_END
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39