Hello!
I am working with the Adafruit NeoPixel library, and I just read that the number of LED's used has an influence on the clock of the Arduino, due to the interrupts being used. I am also experiencing problems with the increase in the LED count in my project.
I am currently making a LED controller using an Arduino Nano Every for a WS2813B-RGBW led strip with 300 LED's. I want to control this strip with my phone over a Wi-Fi module (Ai-Thinker ESP8266 WiFi Module ESP-01S), but I am currently still using the Arduino IDE for all the serial communication. (The Wi-Fi module is not yet connected)
The problem that I (think I) am having is that the Serial-in is not processed correctly due to all the interrupts from the NeoPixel library. Is there a way to call those functions as an interrupt when Serial-in is detected? Or prevent an interrupt happening when those functions are called? Or maybe something else?
The code included is the serial receive code, as you can see, I already tried the noInterrupts() function, but this did not gave any improvements. I am also currently reading: Gammon Forum : Electronics : Microprocessors : Interrupts but it is a bit complex for me at the moment.
In advance: thanks!
void loop() {
//noInterrupts();
recvWithStartEndMarkers();
if (newData == true) {
strcpy(tempChars, receivedChars);
parseData();
newData = false;
}
// interrupts();
//The_other_stuff();
}
void parseData() { // split the data into its parts
Serial.println("Serial Input Registered:");
char* strtokIndx; // this is used by strtok() as an index
strtokIndx = strtok(tempChars, ","); // get the first part - the string
float bgOrfx = atof(strtokIndx); // convert this part to a float
strtokIndx = strtok(NULL, ",");
bgOn = atof(strtokIndx);
strtokIndx = strtok(NULL, ",");
inFX = *strtokIndx;
strtokIndx = strtok(NULL, ",");
float intensity = atof(strtokIndx); // convert this part to a float
strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
float red = atof(strtokIndx);
strtokIndx = strtok(NULL, ",");
float green = atof(strtokIndx);
strtokIndx = strtok(NULL, ",");
float blue = atof(strtokIndx);
strtokIndx = strtok(NULL, ",");
float white = atof(strtokIndx);
strtokIndx = strtok(NULL, ",");
fxSpeed = atof(strtokIndx);
strtokIndx = strtok(NULL, ",");
fxSize = atof(strtokIndx);
stripColors(intensity, red, green, blue, white, bgOrfx);
}
//The code for reading the Serial input. This is not made by me!
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
} else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
} else if (rc == startMarker) {
recvInProgress = true;
}
}
}