Skip to main content
Arduino

Return to Revisions

2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/

After reading comments i got some more clues where to search and indeed the problem was somewhat in the inheritance and how i was calling the functions. This post helped me find the problem.

I forgot to post the piece of code where i was creating the patterns in the Main Sketch, this is how it was initially:

Pattern ledPatterns[NUM_PATTERNS];
ledPatterns[0] = TestPattern(NUM_LEDS, "Test Pattern 1", TestPat, 0, 0);
ledPatterns[1] = TestPattern(NUM_LEDS, "Test Pattern 2", TestPat, 0, 1);
...
ledPatterns[p].Tick(millis());
...

When i later called ledPatterns.Tick (the function that modifies the values, the function actually being called was the parent and not the child. Thus the unexpected result.

This is how i should have been initializing the patterns, since they are inherited:

Pattern* ledPatterns[NUM_PATTERNS];
ledPatterns[0] = new TestPattern(NUM_LEDS, "Test Pattern 1", TestPat, 0, 0);
ledPatterns[1] = new TestPattern(NUM_LEDS, "Test Pattern 2", TestPat, 0, 1);
...
ledPatterns[p]->Tick(millis());
...

Sorry for the huge confusion, i thought the problem was in a completely different part of the code

AltStyle によって変換されたページ (->オリジナル) /