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