FastLED 3.9.15
Loading...
Searching...
No Matches
rectangular_draw_buffer.h
Go to the documentation of this file.
1
2#pragma once
3
4#include <stdint.h>
5
6#include "fl/map.h"
7#include "fl/namespace.h"
8#include "fl/scoped_ptr.h"
9#include "fl/slice.h"
10#include "fl/vector.h"
11
12namespace fl {
13
14struct DrawItem {
15 DrawItem() = default;
16 DrawItem(uint8_t pin, uint16_t numLeds, bool is_rgbw);
17 uint8_t mPin = 0;
18 uint32_t mNumBytes = 0;
19 bool mIsRgbw = false;
20 bool operator!=(const DrawItem &other) const {
21 return mPin != other.mPin || mNumBytes != other.mNumBytes ||
22 mIsRgbw != other.mIsRgbw;
23 }
24};
25
26// Needed by controllers that require a compact, rectangular buffer of pixel
27// data. Namely, ObjectFLED and the I2S controllers. This class handles using
28// multiple independent strips of LEDs, each with their own buffer of pixel
29// data. The strips are not necessarily contiguous in memory. One or more
30// DrawItems containing the pin number and number are queued up. When the
31// queue-ing is done, the buffers are compacted into the rectangular buffer.
32// Data access is achieved through a Slice<uint8_t> representing the pixel data
33// for that pin.
35 public:
37 // We manually manage the memory for the buffer of all LEDs so that it can
38 // go into psram on ESP32S3, which is managed by fl::LargeBlockAllocator.
45
48
51
53 bool clear_first = true);
54
55 // Safe to call multiple times before calling queue() once. Returns true on
56 // the first call, false after.
57 bool onQueuingStart();
58 void queue(const DrawItem &item);
59
60 // Safe to call multiple times before calling onQueueingStart() again.
61 // Returns true on the first call, false after.
62 bool onQueuingDone();
63 uint32_t getMaxBytesInStrip() const;
64 uint32_t getTotalBytes() const;
65 void getBlockInfo(uint32_t *num_strips, uint32_t *bytes_per_strip,
66 uint32_t *total_bytes) const;
67};
68
69} // namespace fl
void getBlockInfo(uint32_t *num_strips, uint32_t *bytes_per_strip, uint32_t *total_bytes) const
fl::HeapVector< DrawItem > DrawList
fl::Slice< uint8_t > getLedsBufferBytesForPin(uint8_t pin, bool clear_first=true)
fl::FixedMap< uint8_t, fl::Slice< uint8_t >, 50 > mPinToLedSegment
void queue(const DrawItem &item)
scoped_array< uint8_t > mAllLedsBufferUint8
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
DrawItem()=default
bool operator!=(const DrawItem &other) const