These are chat archives for Makuna/NeoPixelBus

25th
Dec 2016
Michael Miller
@Makuna
Dec 25 2016 09:33

Think of each "word" instead of a function, as a number. You can use an enum to abstract this for you if you want like...

enum Word
{
    Word_Near,  // this automatically is assigned the value 0
    Word_blah, // this automatically is assigned the value of 1
   // and so on
   Word_COUNT // the last one will represent how many words total
};

You can see then these could be used in my example above.
THEN, instead of having a function like you have above, store the data in a data structure like....

struct WordLocation
{
    uint8_t firstX;
    uint8_t firstY;
    uint8_t lastX;
    uint8_t lastY;
}
const WordLocation WordLocations[Word_COUNT] = 
{
    {0, 0,    3, 0}, // firstX, firstY, lastX, lastY
    // repeat for every word
};

Now you can reference this by the animationUpdate function by a double for loop over x ranges and y ranges instead of the single index I showed