I can't really see any obvious reason for what you experience, but I know that the RGBmatrixPanel
lib can be a time hog on the controller, since it does the LED dimming via highly frequent interrupts (maybe @peekay123 can chime in on the RGBmatrixPanel
front ;-)).
Additionally the interaction between your subscribe()
and your publish()
might also contribute to the issue, so see my tip about string parsing further down.
Also add some Particle.process()
calls in any of the potentially longer running loops (e.g. inside gotScoreData()
and circleWipe()
) just to be on the safe side.
You could also add some Serial.println()
debug statements to see if your millis()
checks don't accidentally fire more often than expected and also how often your other functions get called (maybe with a Serial.printf("Enter: %d", millis());
at the top of the function and Serial.printf("Leave: %d", millis());
at the end).
The following hints might not immediately have to do with your problem, but just for the sake of saying it
Just curious, what is this final && millis()
for?
For parsing your color string, you might like to look into strtok()
, which makes it a bit tidier and avoids the use of String
objects, which will eventually lead to heap exhaustion, if your code is running for a long time.
The same goes for getScoreData()
.
I'd also replace your String
compares with something like if (strcmp(team.c_str(), "ANA") == 0)
to avoid implicit String
creation with the same side effects on the heap as mentioned above.