FastLED 3.9.7
Loading...
Searching...
No Matches
pixel_stream.h
1#pragma once
2
3#include "fl/namespace.h"
4#include "crgb.h"
5#include "fl/ptr.h"
6#include "fl/bytestream.h"
7#include "fl/file_system.h"
8#include "fx/frame.h"
9namespace fl {
10FASTLED_SMART_PTR(FileHandle);
11FASTLED_SMART_PTR(ByteStream);
12}
13
14namespace fl {
15
16FASTLED_SMART_PTR(PixelStream);
17
18
19// PixelStream takes either a file handle or a byte stream
20// and reads frames from it in order to serve data to the
21// video system.
23 public:
24
25 enum Type {
26 kStreaming,
27 kFile,
28 };
29
30 explicit PixelStream(int bytes_per_frame);
31
32 bool begin(fl::FileHandlePtr h);
33 bool beginStream(fl::ByteStreamPtr s);
34 void close();
35 int32_t bytesPerFrame();
36 bool readPixel(CRGB* dst); // Convenience function to read a pixel
37 size_t readBytes(uint8_t* dst, size_t len);
38
39 bool readFrame(Frame* frame);
40 bool readFrameAt(uint32_t frameNumber, Frame* frame);
41 bool hasFrame(uint32_t frameNumber);
42 int32_t framesRemaining() const;
43 int32_t framesDisplayed() const;
44 bool available() const;
45 bool atEnd() const;
46
47 int32_t bytesRemaining() const;
48 int32_t bytesRemainingInFrame() const;
49 bool rewind(); // Returns false on failure, which can happen for streaming mode.
50 Type getType() const; // Returns the type of the video stream (kStreaming or kFile)
51
52 private:
53 void init(int bytes_per_frame);
54 int32_t mbytesPerFrame;
55 fl::FileHandlePtr mFileHandle;
56 fl::ByteStreamPtr mByteStream;
57 bool mUsingByteStream;
58
59protected:
60 virtual ~PixelStream();
61};
62
63} // namespace fl
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54