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