#include <FastLED.h>
#include "LedMatrix.h"


//CRGB Leds[512];
//FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(Leds, 64, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE);

const uint8_t width=64;
const uint8_t height=16;
const uint8_t led_width=8;
const uint8_t led_height=8;
//const uint8_t pin=12;
LedMatrix* M=new LedMatrix(width, height, led_width, led_height);

byte x, y, dx, dy;

void setup() {
  Serial.begin(115200);

  //FastLED.addLeds<WS2812B, 12, GRB>(Leds, 64);

  for (uint16_t i=0; i<width*height;i++) {
    M->Buffer[i]=CHSV(random8(255), 255,255);
  }

  byte x=6;
  byte y=3;

  for (byte i=0; i<led_width; i++) {
    SetPixel(x+i, y);
    SetPixel(x+i, y+led_height-1);
  }
  for (byte i=0; i<led_height; i++) {
    SetPixel(x, y+i);
    SetPixel(x+led_width-1, y+i);
  }


  dx=1; dy=1;
}

void SetPixel( uint8_t x, uint8_t y) {
  M->Buffer[x+y*width]=CRGB::White;
}



void loop() {
  x=x+dx; if (x==0 || x==width) dx=-dx;
  y=y+dy; if (y==0 || y==height) dy=-dy;

  M->Show(x,y);
  FastLED.delay(100);
}