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 "fl/stdint.h"
5
6#include "fl/int.h"
7#include "fl/map.h"
8#include "fl/namespace.h"
9#include "fl/scoped_array.h"
10#include "fl/span.h"
11#include "fl/vector.h"
12
13namespace fl {
14
15struct DrawItem {
16 DrawItem() = default;
17 DrawItem(u8 pin, u16 numLeds, bool is_rgbw);
18
19 // Rule of 5 for POD data
20 DrawItem(const DrawItem &other) = default;
21 DrawItem &operator=(const DrawItem &other) = default;
22 DrawItem(DrawItem &&other) noexcept = default;
23 DrawItem &operator=(DrawItem &&other) noexcept = default;
24
25 u8 mPin = 0;
26 u32 mNumBytes = 0;
27 bool mIsRgbw = false;
28 bool operator!=(const DrawItem &other) const {
29 return mPin != other.mPin || mNumBytes != other.mNumBytes ||
30 mIsRgbw != other.mIsRgbw;
31 }
32};
33
34// Needed by controllers that require a compact, rectangular buffer of pixel
35// data. Namely, ObjectFLED and the I2S controllers. This class handles using
36// multiple independent strips of LEDs, each with their own buffer of pixel
37// data. The strips are not necessarily contiguous in memory. One or more
38// DrawItems containing the pin number and number are queued up. When the
39// queue-ing is done, the buffers are compacted into the rectangular buffer.
40// Data access is achieved through a span<u8> representing the pixel data
41// for that pin.
43 public:
45 // We manually manage the memory for the buffer of all LEDs so that it can
46 // go into psram on ESP32S3, which is managed by fl::PSRamAllocator.
53
56
59
61 bool clear_first = true);
62
63 // Safe to call multiple times before calling queue() once. Returns true on
64 // the first call, false after.
65 bool onQueuingStart();
66 void queue(const DrawItem &item);
67
68 // Safe to call multiple times before calling onQueueingStart() again.
69 // Returns true on the first call, false after.
70 bool onQueuingDone();
71 u32 getMaxBytesInStrip() const;
72 u32 getTotalBytes() const;
73 void getBlockInfo(u32 *num_strips, u32 *bytes_per_strip,
74 u32 *total_bytes) const;
75};
76
77} // namespace fl
fl::HeapVector< DrawItem > DrawList
fl::span< u8 > getLedsBufferBytesForPin(u8 pin, bool clear_first=true)
fl::FixedMap< u8, fl::span< u8 >, 50 > mPinToLedSegment
void getBlockInfo(u32 *num_strips, u32 *bytes_per_strip, u32 *total_bytes) const
void queue(const DrawItem &item)
Implements the FastLED namespace macros.
unsigned char u8
Definition int.h:17
Slice< T > span
Definition span.h:8
IMPORTANT!
Definition crgb.h:20
DrawItem(const DrawItem &other)=default
DrawItem()=default
DrawItem & operator=(DrawItem &&other) noexcept=default
DrawItem(DrawItem &&other) noexcept=default
bool operator!=(const DrawItem &other) const
DrawItem & operator=(const DrawItem &other)=default