Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Multitasking
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Multitasking

by AndyWilx on Fri Aug 14, 2020 8:43 am

BINGO!!!!

Thank you so much.
Apologies for needing so much hand holding.
I would love to say I understand what you have done.
Where is the index effected with in the pattern setup?
(I'm good at good-old Basic... GOTO FOR NEXT LOOP IF NOT THEN ALSO.)

I will be sure to give you the coding credit when my project goes public.

This is perfect, thank you again.

Andy

P.S. next stop, replace the RainbowCycle with an audio responsive pattern... I'LL BE BACK ;o)

AndyWilx
 
Posts: 8
Joined: Mon Aug 10, 2020 8:12 am

Re: Multitasking

by adafruit_support_bill on Fri Aug 14, 2020 9:00 am

The Index keeps track of where you are in the animation. The issue was here in the Increment() function:
Code: Select all | TOGGLE FULL SIZE
    void Increment()
    {
        if (Direction == FORWARD)
        {
           Index++;
           if (Index >= TotalSteps)
            {
                Index = 0;
                if (OnComplete != NULL)
                {
                    OnComplete(); // call the comlpetion callback
                }
            }
        }
        else // Direction == REVERSE
        {
            --Index;
            if (Index <= 0)
            {
                Index = TotalSteps-1;
                if (OnComplete != NULL)
                {
                    OnComplete(); // call the comlpetion callback
                }
            }
        }
    }

When it gets to the end, it resets the index *before* calling the completion callback. So when you reverse, the index is already at zero so it immediately completes and goes forward again.

adafruit_support_bill
 
Posts: 78758
Joined: Sat Feb 07, 2009 10:11 am

Re: Multitasking

by AndyWilx on Fri Aug 14, 2020 9:08 am

That makes sense.
Thank you so much again.

Andy

AndyWilx
 
Posts: 8
Joined: Mon Aug 10, 2020 8:12 am

Please be positive and constructive with your questions and comments.