// ArrayOfLedArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
// using multiple controllers
// TOD FIX COLOURS STINKY
// Differences between this simulator and our actual display:
// 1) The simulator is a bit laggy
// 2) The data, VSS, and GND pins are attached to the strip closest
// to the LED with index 0. We'll want to mount the LED strips with
// the wiring on the left side of the display if we want to keep this
// coordinate system
#include <FastLED.h>
#define NUM_STRIPS 8
#define NUM_LEDS_PER_STRIP 32
#define ANIFRAMES 7//Number of frames in the animation to be shown
// leds[0][0] is the bottom left corner
// leds[0][31] is the bottom right corner
// leds[31][0] is the top left corner
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
//DELETING THIS ARRAY SEEMS TO MAKE EVERYTHING GO HUNKY DORY AND I AM WAY TOO TIRED TO FIGURE OUT WHY
void setup() {
// tell FastLED there's 32 WS2812B leds on pins 10-41
FastLED.addLeds<WS2812B, 10, GRB>(leds[0], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 11, GRB>(leds[1], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 12, GRB>(leds[2], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 13, GRB>(leds[3], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 14, GRB>(leds[4], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 15, GRB>(leds[5], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 16, GRB>(leds[6], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 17, GRB>(leds[7], NUM_LEDS_PER_STRIP);
//FastLED.clear();
Serial.begin(9600);
Serial.println("Serial start");//The serial is only starting this...
//int *randomImage=(int *)malloc(32*32*3*sizeof(int));
//generateRandomImage(randomImage);
//displayImage(randomImage);
// Example of reading file from the card:
}
void loop() {
//animate(new_piskel_data, 10, ANIFRAMES-1);
/*Serial.println(leds[11][7].r);
Serial.println(leds[11][7].g);
Serial.println(leds[11][7].b);*/
for(int i=0; i<NUM_STRIPS; i++){
for(int j=0; j<NUM_LEDS_PER_STRIP; j++){
leds[i][j]=CRGB(0x0000ff);
FastLED.show();
delay(50);
FastLED.clear();
delay(50);
}
}
delay(1000);
FastLED.show();
//moveRow(0,1,500,0xffffff,-1);
//scrollLetter(0xffffff,0,27,100,'A',-1);
//scrollLetters(2,10,0xff0000,"AS?",3);
delay(500);
}
//current note to self on how I could do this (scrolltext):
/*Since I'm using 5x5s in the same font, here's what I could do.
Each letter is just 5 sequences of 5-bit numbers. Those 5 numbers represent whether a pixel is ON or OFF. So, in the case of A:
So each letter is stored by its 25-bit sequence. From there, for each letter, just scroll it sequence by sequence.
Note to self: make a function that generates these 25-bIt numbers
*/
//This one generates a random picture, shows it, and then frees the memory. USE AT YOUR OWN RISK:
//This one generates a 32x32x32 (7.4kB) array so it will almost definitely fuck up your SRAM and not work unless you don't have much code.
//Clear the display
void clearDisplay(){
FastLED.clear();
FastLED.show();
}
void changePixel(uint32_t hex, int i, int j){
leds[i][j]=CRGB(hex);
FastLED.show();
}
void changePixel(uint8_t R, uint8_t G, uint8_t B, int i, int j){
leds[i][j]=CRGB(R,G,B);
FastLED.show();
}
//Needs to return to what it was before.
void scrollPixel(uint32_t color, int rrow, int del){
int row=(rrow<NUM_STRIPS)? rrow:(NUM_STRIPS-1);
row=(row>=0)?row:0;
CRGB prev=leds[row][0];
for(int i=0; i<NUM_LEDS_PER_STRIP; i++){
if(i>0){
leds[row][i-1]=prev;
}
prev=leds[row][i];
leds[row][i]=CRGB(color);
FastLED.show();
delay(del);
}
leds[row][NUM_LEDS_PER_STRIP-1]=CRGB::Black;
FastLED.show();
}