I'm getting garbage data, so I know there is a problem here.
const int numOfChans = 8;
int chanCurr[numOfChans] = {0, 0, 0, 0, 0, 0, 0, 0};
int chanTarg[numOfChans] = {0, 0, 0, 0, 0, 0, 0, 0};
int chanSmooth[numOfChans] = {0, 0, 0, 0, 0, 0, 0, 0};
const int q1[numOfChans] = {36, 100, 255, 0, 0, 0, 0, 0};
const int q2[numOfChans] = {0, 18, 255, 76, 4, 0, 0, 0};
const int numOfQs = 2;
//I believe this is making an array of int array pointers
int *qLookup[numOfQs];
//I don't understand why these need to be in a function to work
void assign() {
qLookup[1] = (const int *) &q1;
qLookup[2] = (const int *) &q2;
}
void setup() {
Serial.begin(9600);
assign();
}
void loop() {
if (Serial.available() > 0) {
int qNumber = Serial.parseInt();
Serial.println(qNumber);
updateChannels(&qLookup[qNumber]); //call the updateChannels() function with the target of item of the array
}
//update all the channels (0 will be reserved for speed of cross-fade)
for (int i = 1; i < numOfChans; i++) {
chanSmooth[i] = ((chanCurr[i] * 9) + chanTarg[i])/10;
}
//Update the lights with Smooth
//use first channel for delay
for (int i = 1; i < numOfChans; i++) {
chanCurr[i] = chanSmooth[i];
}
}
void updateChannels(int *q[]) {
//function should take in a pointer to an int array
for (int i = 0; i < numOfChans; i++) {
//print out the values as they are updated (I'm getting garbage here)
int currI = *q[i];
Serial.println(currI);
chanCurr[i] = *q[i];
}
}