Hello,
I am currently experimenting with the FastLed libraray in order to build my own Pixel POI.
Today I experienced a strange behaviour.
Here is my Code
#include "FastLED.h"
#define LED_PIN 5
#define CLOCK_PIN 6
#define NUM_LEDS 64
#define LED_TYPE APA102
#define COLOR_ORDER BGR
CRGB leds[NUM_LEDS];
int currentDelay = 5;
int intermission = 500;
int currentMode = 1;
int currentBrightness = 255;
void setup() {
delay(3000); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(currentBrightness);
FastLED.clear();
FastLED.show();
Serial.begin(9600); // HC-05 default speed in AT command more
}
byte OutImage2[95][64][3] = {
{
{1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {2, 1, 1}, {17, 1, 1}, {77, 23, 13}, {163, 41, 5}, {217, 59, 2}, {236, 73, 2}, {249, 85, 1}, {254, 113, 6}, {254, 141, 10}, {227, 120, 15}, {131, 58, 12}, {52, 16, 10}, {25, 6, 8}, {30, 12, 8}, {104, 38, 3}, {222, 122, 14}, {254, 188, 15}, {249, 194, 5}, {251, 161, 11},.....
};
void loop() {
switch (currentMode) {
case 2:
ShowPOVMatrix(OutImage2, 94);
FastLED.clear();
FastLED.show();
CheckSerial();
break;
}
if (currentMode != 3) {
pollingDelay(intermission);
}
}
void ShowPOVMatrix(byte ca[][64][3], int Width) {
for (int row = 0; row < Width; row++) {
for (int column = 0; column <= 64; column++) {
int R = ca[row][column][0];
int G = ca[row][column][1];
int B = ca[row][column][2];
leds[64-column] = CRGB(R, G, B);
Serial.println(R);
}
FastLED.show();
delay(200);
}
}
void CheckSerial() {
int AvailBytes = Serial.available();
String newDelay = "";
String newBrightness = "";
String newMode = "";
char buffer[64];
int index = 0;
if (AvailBytes > 0)
{
char command = Serial.read();
bool othercommands = false;
while (Serial.available() && !othercommands) {
char current = Serial.read();
if (current == '|' && Serial.available()) {
othercommands = true;
}
if (!othercommands) {
buffer[index] = current;
index++;
}
}
switch (command) {
case 'D':
newDelay = buffer;
currentDelay = newDelay.toInt();
break;
case 'I':
newDelay = buffer;
intermission = newDelay.toInt();
break;
case 'B':
newBrightness = buffer;
currentBrightness = newBrightness.toInt();
FastLED.setBrightness(currentBrightness);
break;
case 'M':
newMode = buffer;
currentMode = newMode.toInt();
break;
}
if (othercommands) {
CheckSerial();
}
}
}
void pollingDelay(int delaytime) {
int incrDelay = 15;
if (delaytime < 15) {
incrDelay = delaytime;
}
while (1 == 1) {
CheckSerial();
delay(incrDelay);
delaytime -= incrDelay;
if (delaytime <= 0) {
return;
}
}
}
When I runt the above Code I get absolutely nothing on my leds, but when I Change the line
leds[64-column] = CRGB(R, G, B);
to i.e.
leds[64-column] = CRGB(255, G, B);
All my leds turn red and I see the green and blue leds changing Color as they are supposed to do.
Am I missing something?
Thanks