#include <FastLED.h>
#define LED_PIN 5
#define NUM_LEDS 170
#define BRIGHTNESS 64
#define WIDTH 17 // ширина матрицы
#define HEIGHT 10 // высота матрицы
#define SEGMENTS 1
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
byte hue;
static const byte maxDim = max(WIDTH, HEIGHT);
void setup()
{
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
}
void loop()
{
rainbowRoutine();
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}
void rainbowRoutine() {
hue += 3;
for (byte i = 0; i < WIDTH; i++) {
CHSV thisColor = CHSV((byte)(hue + i * float(255 / WIDTH)), 255, 255);
for (byte j = 0; j < HEIGHT; j++)
leds[getPixelNumber(i, j)] = thisColor;
}
}
// *********** радуга дигональная ***********
void rainbowDiagonalRoutine() {
hue += 3;
for (byte x = 0; x < WIDTH; x++) {
for (byte y = 0; y < HEIGHT; y++) {
CHSV thisColor = CHSV((byte)(hue + (float)(WIDTH / HEIGHT * x + y) * (float)(255 / maxDim)), 255, 255);
leds[getPixelNumber(x, y)] = thisColor;
}
}
}
uint16_t getPixelNumber(int8_t x, int8_t y) {
return (x)*(y);
}