Hi,
I am struggling to debug NeoPixel RGBW for an artistic project. I get weird result which stops me to go further on a more complex Script. I tried to isolate the problem, but comment ting a lot o features of my script to reduce the purpose.
I am using the Neopixel Library on an arduino 33 iOt with a proper level shifter circuit and an external Power Supply.
The main problem I have is in this comment, setting manually the color causes issues, so playing with more complex effects is not really possible.
// uint32_t waveColor1 = 0x00FF0000; // produce Steady RED ok
// uint32_t waveColor1 = 0xFF000000; // produce Steady WHITE ok
// uint32_t waveColor1 = 0x0000FF00; // produce Steady GREEN ok
// uint32_t waveColor1 = 0x000000FF; // produce Steady BLUE ok
uint32_t waveColor1 = 0x00FFFFFF; // produce Flashing RED ??? Should produce steady WHITE, by combining RGB
Any comment or clues to help me debug this situation, on which I already spent few hours.
Full Code:
// Led Libraries
#include <Adafruit_NeoPixel.h>
extern const uint8_t gamma8[]; // refer to Gamma table at end of sketch.
// Led Code Begin //
#define LED_PIN 2
#define NUM_PIXELS 37
#define BRIGHTNESS 50
Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_GRBW + NEO_KHZ800);
// Led Code End //
//[GLOBAL_VARIABLES]
unsigned long currentMillis;
unsigned long lastMillis;
unsigned long effStart;
uint16_t effStep;
int curr = 1 ;
int reduction = 2; // divider for intensity
uint8_t arrayLen = 7;
int oldWave = 1;
int wave = 1;
int waveColor1_R = 255;
int waveColor1_G = 255;
int waveColor1_B = 255;
int waveColor1_W = 255;
int glowColor1_R = 115;
int glowColor1_G = 205;
int glowColor1_B = 255;
int glowColor1_W = 0;
int glowColor2_R = 20;
int glowColor2_G = 170;
int glowColor2_B = 155;
int glowColor2_W = 0;
int bgColor_R = 0;
int bgColor_G = 65;
int bgColor_B = 135;
int bgColor_W = 0;
// uint32_t curve1[] = {21,20,19,18,17,16,15};
// uint32_t curve2[] = {14,20,19,18,17,16,22};
// uint32_t curve3[] = {14,13,19,18,17,23,22};
// uint32_t curve4[] = {7,12,18,24,29};
// uint32_t curve5[] = {2,6,11,18,25,30,34};
// uint32_t curve6[] = {2,5,11,18,25,31,34};
// uint32_t curve7[] = {1,5,11,18,25,31,35};
// uint32_t curve8[] = {0,5,11,18,25,31,36};
// uint32_t curve9[] = {0,4,11,18,25,32,36};
// uint32_t curve10[] = {3,10,18,26,33};
// uint32_t curve11[] = {8,9,17,18,19,27,28};
// uint32_t curve12[] = {8,16,17,18,19,20,28};
// uint32_t curve13[] = {15,16,17,18,19,20,21};
uint32_t curve7[][7] = { {0,0,0,0,0,0,0},
{21,20,19,18,17,16,15},
{14,20,19,18,17,16,22},
{14,13,19,18,17,23,22},
{4,4,4,4,4,4,4},
{2,6,11,18,25,30,34},
{2,5,11,18,25,31,34},
{1,5,11,18,25,31,35},
{0,5,11,18,25,31,36},
{0,4,11,18,25,32,36},
{10,10,10,10,10,10,10},
{8,9,17,18,19,27,28},
{8,16,17,18,19,20,28},
{15,16,17,18,19,20,21} };
uint32_t curve5[][5] = { {0,0,0,0,0},
{1,1,1,1,1},
{2,2,2,2,2},
{3,3,3,3,3},
{7,12,18,24,29},
{5,5,5,5,5},
{6,6,6,6,6},
{7,7,7,7,7},
{8,8,8,8,8},
{9,9,9,9,9},
{3,10,18,26,33},
{11,11,11,11,11},
{12,12,12,12,12},
{13,13,13,13,13} };
uint32_t percent7[][35] = {
{64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64},
{64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64},
{64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64},
{64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83},
{159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179},
{255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236},
{159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140}};
uint32_t percent5[][35] = {
{64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64},
{64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64},
{64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64},
{64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83},
{159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179}};
uint32_t Glow11[14] = {8,9,10,11,12,13,14,22,23,24,25,26,27,28};
uint32_t Glow21[10] = {3,4,5,6,7,29,30,31,32,33};
uint32_t GlowB1[6] = {0,1,2,34,35,36};
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
effStart = millis();
strip.begin();
strip.show();
//delay(1000);
}
void loop() {
currentMillis = millis();
strips_loop();
}
void strips_loop() {
stripCurve();
strip.show();
delay(200);
}
void stripCurve() {
uint32_t color1 = strip.gamma32(strip.Color(glowColor1_R,glowColor1_G,glowColor1_B,glowColor1_W));
uint32_t color2 = strip.gamma32(strip.Color(glowColor2_R,glowColor2_G,glowColor2_B,glowColor2_W));
uint32_t colorb = strip.gamma32(strip.Color(bgColor_R,bgColor_G,bgColor_B,bgColor_W));
// uint32_t waveColor1 = strip.gamma32(strip.Color(waveColor1_R,waveColor1_G,waveColor1_B));
// uint32_t waveColor1 = strip.Color(waveColor1_R,waveColor1_G,waveColor1_B);
// uint32_t waveColor1 = 0x00FF0000; // produce Steady RED
// uint32_t waveColor1 = 0xFF000000; // produce Steady WHITE
// uint32_t waveColor1 = 0x0000FF00; // produce Steady GREEN
// uint32_t waveColor1 = 0x000000FF; // produce Steady BLUE
uint32_t waveColor1 = 0x00FFFFFF; // produce Flashing RED ???
Serial.println(waveColor1);
Serial.println(waveColor1);
int t = effStep;
//if(millis() - effStart < 200 * effStep) return ;
for (int i=0; i < arrayLen; i++) {
// uint32_t gamma = pgm_read_byte(&gamma8[percent7[i][t]]);
// strip.gamma32(strip.Color(0,0,0,0));
//uint32_t colorit = strip.Color(0,0,0,pgm_read_byte(&gamma8[percent7[i][t]]));
// strip.setPixelColor(curve7[wave][i], colorit );
strip.setPixelColor(curve7[wave][i], waveColor1 );
// for (int a = 0 ; a < 14 ; a++) {
// strip.setPixelColor(Glow11[a], colorb);
// }
// for (int b = 0 ; b < 10 ; b++) {
// strip.setPixelColor(Glow21[b], colorb);
// }
// for (int c = 0 ; c < 6 ; c++) {
// strip.setPixelColor(GlowB1[c], colorb);
// }
//strip.setPixelColor(curve7[wave][i], 0,0,0, gamma );
// Serial.print(i);
// Serial.print(" ");
// Serial.print(t);
// Serial.print(" ");
// Serial.print(percent7[i][t]);
// Serial.print(" gamma: ");
// //Serial.print(gamma);
// Serial.print(" led: ");
// Serial.println(curve7[wave][i]);
// Serial.println("case default");
}
if(effStep >= 34) {
effStart = millis();
effStep = 0;
}
else effStep++;
return;
}
const uint8_t PROGMEM gamma8[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };





