FastLED 3.9.15
Loading...
Searching...
No Matches
leds.cpp
Go to the documentation of this file.
1
2#include "fl/leds.h"
3#include "crgb.h"
4#include "fl/assert.h"
5#include "fl/xymap.h"
6
7namespace fl {
8
10
12 if (!mXyMap.has(x, y)) {
13 return empty();
14 }
15 return mLeds[mXyMap(x, y)];
16}
17
19 static CRGB empty_led;
20 return empty_led;
21}
22
23const CRGB &Leds::operator()(int x, int y) const {
24 if (!mXyMap.has(x, y)) {
25 return empty();
26 }
27 return mLeds[mXyMap(x, y)];
28}
29
31 FASTLED_ASSERT(mXyMap.isSerpentine() || mXyMap.isLineByLine(),
32 "XYMap is not serpentine or line by line");
33 return &mLeds[mXyMap(0, y)];
34}
35const CRGB *Leds::operator[](int y) const {
36 FASTLED_ASSERT(mXyMap.isSerpentine() || mXyMap.isLineByLine(),
37 "XYMap is not serpentine or line by line");
38 return &mLeds[mXyMap(0, y)];
39}
40
41Leds::Leds(CRGB *leds, uint16_t width, uint16_t height)
42 : Leds(leds, XYMap::constructRectangularGrid(width, height)) {}
43
44} // namespace fl
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
const XYMap & xymap() const
Definition leds.h:39
Leds(CRGB *leds, uint16_t width, uint16_t height)
Definition leds.cpp:41
size_t height() const
Definition leds.h:29
CRGB & operator()(int x, int y)
Definition leds.cpp:11
XYMap mXyMap
Definition leds.h:52
static CRGB & empty()
Definition leds.cpp:18
CRGB * operator[](int x)
Definition leds.cpp:30
size_t width() const
Definition leds.h:28
CRGB * mLeds
Definition leds.h:53
Defines the red, green, and blue (RGB) pixel struct.
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:55