// https://www.reddit.com/r/FastLED/comments/16b75d7/diagonal_candycane_fx_on_3_x_30_grid/

#include "FastLED.h"

// serpentine layout of 3 strips each with 32 LEDs
CRGBArray<96> leds;
CRGBSet strips[] = {
  leds(0, 31),
  leds(63, 32),
  leds(64, 95),
};

void setup() {
  FastLED.addLeds<NEOPIXEL, 3>(leds, leds.size());

  for (uint8_t x = 0; x < 3; x++) {
    for (uint8_t y = 0; y < 32; y++) {
      strips[x][y] = CRGB::Grey;
      FastLED.delay(10);
    }
  }

  for (CRGBSet& strip : strips) {
    for (CRGB& pixel : strip) {
      pixel = CRGB::Black;
      FastLED.delay(10);
    }
  }
}

void loop() {
  uint8_t widthRed = 8;
  uint8_t widthWhite = 8;

  // animate the speed of animation slowly over time. To allow fine
  // control of speed, the units are 1/256ths of pixel per frame.
  int16_t speed = (sin8(millis() / 64) - 128) / 2;

  // move the start position on each frame
  static uint16_t basePos = 0;
  basePos += speed;

  // switch units from 1/256ths of pixel to 1 pixel
  uint16_t stripPos = basePos / 256;

  for (CRGBSet& strip : strips) {
    // offset the start of each strip by 1 pixel to get diagonal stripes
    stripPos += 1;
    uint16_t pixPos = stripPos;

    for (CRGB& pixel : strip) {
      pixPos += 1;
      // use the Modulus operator to determine the colour for this pixel
      if (pixPos % (widthRed + widthWhite) < widthRed) {
        pixel = CRGB::Red;
      } else {
        pixel = CRGB::White;
      }
    }
  }
  FastLED.show();
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
neopixels1:DOUT
neopixels1:VDD
neopixels1:VSS
neopixels1:DIN
FPS: 0
Power: 0.00W