FastLED 3.9.15
Loading...
Searching...
No Matches
leds.cpp.hpp
Go to the documentation of this file.
1
2
3#include "fl/gfx/leds.h"
4#include "crgb.h"
5#include "fl/stl/assert.h"
6#include "fl/math/xymap.h"
7
8namespace fl {
9
10Leds::Leds(CRGB *leds, const XYMap &xymap) : mXyMap(xymap), mLeds(leds, xymap.getTotal()) {}
11
13 if (!mXyMap.has(x, y)) {
14 return empty();
15 }
16 return mLeds[mXyMap(x, y)];
17}
18
20 static CRGB empty_led;
21 return empty_led;
22}
23
24const CRGB &Leds::operator()(int x, int y) const {
25 if (!mXyMap.has(x, y)) {
26 return empty();
27 }
28 return mLeds[mXyMap(x, y)];
29}
30
32 FASTLED_ASSERT(mXyMap.isSerpentine() || mXyMap.isLineByLine(),
33 "XYMap is not serpentine or line by line");
34 return &mLeds[mXyMap(0, y)];
35}
36const CRGB *Leds::operator[](int y) const {
37 FASTLED_ASSERT(mXyMap.isSerpentine() || mXyMap.isLineByLine(),
38 "XYMap is not serpentine or line by line");
39 return &mLeds[mXyMap(0, y)];
40}
41
43 : Leds(leds, XYMap::constructRectangularGrid(width, height)) {}
44
45
46
47} // namespace fl
fl::CRGB leds[NUM_LEDS]
const XYMap & xymap() const
Definition leds.h:41
fl::size width() const
Definition leds.h:30
CRGB & operator()(int x, int y)
Definition leds.cpp.hpp:12
fl::span< CRGB > mLeds
Definition leds.h:57
Leds(CRGB *leds, u16 width, u16 height)
Definition leds.cpp.hpp:42
XYMap mXyMap
Definition leds.h:56
static CRGB & empty()
Definition leds.cpp.hpp:19
fl::size height() const
Definition leds.h:31
CRGB * operator[](int x)
Definition leds.cpp.hpp:31
Defines the 8-bit red, green, and blue (RGB) pixel type in the fl namespace.
Base definition for an LED controller.
Definition crgb.hpp:179
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38