I am trying to convert a sketch into one that uses a class so I have have multiple instances of a led animation routine running on the same strip concurrently. This is the first time I've tried to make a class. I am wondering about how the variables within the class are shared if at all among instances.
I have a simple structure: variable declaration, variable initialization, and then an Update function that is polled from the main loop(). There is a check at the start of the update function to see if it's time to run the update function. Then if it is, it runs the update function and at the end of the update function it sets the last update time to the current time. But the last update time is changing unexpectedly when checked on the next function call, initially resetting to 0, and then by some random amount to the previous. I'm not sure what is happening, I have more println statements than code at this point to try to debug it. Can anyone see what's wrong? Thanks.
class Ripple
{
int updateInterval;
long lastUpdate;
public:
Ripple(int xPos, int rColor, int gColor, int bColor)
{
updateInterval = 2000;
}
void Update()
{
if ((millis() - lastUpdate) > updateInterval) // time to update
{
more code here...
lastUpdate = millis();
}