Hello!
I have been trying to figure out why this bit of code hangs right after the Setup() function and before it hits the main Loop ()
I believe it has to do with how I'm handling the Neo Pixel objects and something with pointers vs objects? I'm really not sure to be honest, I know enough coding to be dangerous but not functional - yet.
Any help would be greatly appreciated, below is the code I have been working with.
#include <Adafruit_NeoPixel.h>
#define NEOPINONE 16
#define togglePinIn 15
// Number of pixels per group need to be defined before init of the strips as pixel array sizes are rquired for the strip init
int currentIndex = 0;
int NumberOfStrips = 1;
int GroupArray[] = {0,4,8}; //used to find the span of each group
int NumberOfGroups = 2;
Adafruit_NeoPixel Strip = Adafruit_NeoPixel(0, NEOPINONE, NEO_RGB); // required for color init?
Adafruit_NeoPixel StripOne = Adafruit_NeoPixel(8, NEOPINONE, NEO_RGB);
//Adafruit_NeoPixel StripTwo = Adafruit_NeoPixel(4, NEOPINONE, NEO_RGB);
uint32_t Red = Strip.Color(225, 0, 0);
uint32_t Blue = Strip.Color(0, 225, 0);
uint32_t Green = Strip.Color(0, 0, 225);
uint32_t Off = Strip.Color(0, 0, 0);
uint32_t Purple = Strip.Color(0, 120, 225);
uint32_t GlobalColor;
bool Output_Debug = true;
int Number_Of_Pins = 2;
//build and array of possible Strips to modfiy
Adafruit_NeoPixel Strips[] = {StripOne};
void setup() {
Serial.begin(9600);
Debug("Start \n");
pinMode(togglePinIn, INPUT_PULLUP);
for(int x = 0; x < NumberOfStrips; x++)
{
Debug("NumberOfStrips index : " + String(x) + "\n");
Adafruit_NeoPixel currentStrip = Strips[x];
currentStrip.begin();
currentStrip.show();
for(int y = 0; y < NumberOfGroups; y++)
{
Debug("NumberOfGroups index : " + String(y) + "\n");
for(int z = GroupArray[y]; z < GroupArray[y + 1]; z++)
{
SetColor(currentStrip, Red, z);
Debug("GroupArray index of : " + String(z) + "\n");
}
}
currentStrip.show();
delay(1000);
ClearAll();
}
Debug("Finished Init \n");
}
void loop() {
Debug("Current Main Loop Index" + String(currentIndex) + "\n");
//Adafruit_NeoPixel test = Strips[0];
//SetColor(test, Green, currentIndex);
//SetColor(test, Off, currentIndex == 4 ? 0 : currentIndex - 1);
StripOne.setPixelColor(currentIndex, Green);
StripOne.setPixelColor(currentIndex == 4 ? 4 : currentIndex - 1, Off);
StripOne.show();
delay(1000);
currentIndex >= 4 ? currentIndex = 0 : currentIndex++;
}
void Debug(String text ) {
if(Output_Debug)
{
Serial.print(text);
}
}
void ClearAll() {
Debug("ClearGroup Called \n");
for(int x = 0; x < NumberOfStrips; x++)
{
Adafruit_NeoPixel workingStrip = Strips[x];
Debug("NumberOfStrips index : " + String(x) + "\n");
for(int y = 0; y < NumberOfGroups; y++)
{
Debug("NumberOfGroups index :" + String(y) + "\n");
ClearGroup(y, workingStrip);
}
}
}
void ClearGroup (int group, Adafruit_NeoPixel &strip) {
for(int x = GroupArray[group]; x < GroupArray[group + 1]; x++)
{
Debug("ClearGroup index : " + String(x) + "\n" );
strip.setPixelColor(x, Off);
}
strip.show();
}
void SetColor (Adafruit_NeoPixel &strip, uint32_t color, int pixel) {
strip.setPixelColor(pixel, color);
}
/*
uint32_t ColorPick(int x, Adafruit_NeoPixel strip ) {
switch (x) {
case 0: return strip.Color(0, 0, 0); //off, needs to be first, hold button seems to defualt to 0
break;
case 1: return strip.Color(0, 225, 0); //red
break;
case 2: return strip.Color(0, 0, 225); //blue
break;
case 3: return strip.Color(225, 0, 0); //green
break;
case 4: return strip.Color(0, 120, 225); //purple
break;
case 5: return colorPick(2);
}
*/