32const uint8_t kMatrixWidth = 16;
33const uint8_t kMatrixHeight = 16;
36const bool kMatrixSerpentineLayout =
true;
37const bool kMatrixVertical =
false;
92uint16_t XY( uint8_t x, uint8_t y)
96 if( kMatrixSerpentineLayout ==
false) {
97 if (kMatrixVertical ==
false) {
98 i = (y * kMatrixWidth) + x;
100 i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
104 if( kMatrixSerpentineLayout ==
true) {
105 if (kMatrixVertical ==
false) {
108 uint8_t reverseX = (kMatrixWidth - 1) - x;
109 i = (y * kMatrixWidth) + reverseX;
112 i = (y * kMatrixWidth) + x;
116 i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
118 i = kMatrixHeight * (kMatrixWidth - x) - (y+1);
169#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
170CRGB leds_plus_safety_pixel[ NUM_LEDS + 1];
171CRGB*
const leds( leds_plus_safety_pixel + 1);
173uint16_t XYsafe( uint8_t x, uint8_t y)
175 if( x >= kMatrixWidth)
return -1;
176 if( y >= kMatrixHeight)
return -1;
181void DrawOneFrame( uint8_t startHue8, int8_t yHueDelta8, int8_t xHueDelta8)
183 uint8_t lineStartHue = startHue8;
184 for( uint8_t y = 0; y < kMatrixHeight; y++) {
185 lineStartHue += yHueDelta8;
186 uint8_t pixelHue = lineStartHue;
187 for( uint8_t x = 0; x < kMatrixWidth; x++) {
188 pixelHue += xHueDelta8;
189 leds[ XY(x, y)] =
CHSV( pixelHue, 255, 255);
205 uint32_t ms = millis();
206 int32_t yHueDelta32 = ((int32_t)
cos16( ms * (27/1) ) * (350 / kMatrixWidth));
207 int32_t xHueDelta32 = ((int32_t)
cos16( ms * (39/1) ) * (310 / kMatrixHeight));
208 DrawOneFrame( ms / 65536, yHueDelta32 / 32768, xHueDelta32 / 32768);
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
@ TypicalSMD5050
Typical values for SMD5050 LEDs.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
LIB8STATIC int16_t cos16(uint16_t theta)
Fast 16-bit approximation of cos(x).
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Representation of an RGB pixel (Red, Green, Blue)