//test matrix layout

#include "FastLED.h"
 
// Matrix size
#define NUM_ROWS 7
#define NUM_COLS 6
#define NUM_LEDS 180
 
// LEDs pin
#define DATA_PIN 5     //led strip pin
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB
 
// LED brightness
#define BRIGHTNESS 255       //bright of leds from 0 to 255 (max) 
#define MAX_POWER_MILLIAMPS 900   //0.9А 
 
// Define the array of leds
CRGB leds[NUM_LEDS];


void setup() {
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  // FastLED.setMaxPowerInVoltsAndMilliamps(5, MAX_POWER_MILLIAMPS);
  FastLED.setBrightness(BRIGHTNESS);
}

void testlayout(){
  static byte index = 0;
  fade_raw(leds, NUM_LEDS, 10);
  leds [index].setHue(sin8((index = ++index%(NUM_LEDS))*255/(NUM_LEDS-1)+millis()/16));
  delay (10);
}


void twincle() {
  static byte offset = 0;
  
  EVERY_N_MILLISECONDS(200) {
    offset++;
  }
  
  random16_set_seed(23579);
  double a = millis();
  for (int i = 0; i < NUM_LEDS; i++) {
    byte hue = sin8((random16() / 256) + inoise8(random16() / 256 + a / 32) + i * 4);
    byte bright = sin8(random16() / 256 + inoise8(random16() / 256 + a / 32) + a / 8);
    nblend(leds[i], CHSV(hue + offset, 255, bright), 128);
  }
  delay(20);
}


void loop() {
  // testlayout();
  twincle();
  FastLED.show();
}