I have an adafruit neopixel 60 led ring and I use several functions to show different light-patterns.
For example:
randomPixelColors(RED, GREEN, BLACK, BLACK, 2);
With the first 4 variables I select the colors I want to use (BLACK is not used but variable should be filled). In this example I only want to use RED and GREEN. With the 5th variable I pass the number of used colors (RED,GREEN), so I can use it as modulo.
It is a little bit confusing, so I would like to pass the colors in an array so I could use 1 variable instead of 5. Is this possible?
pseudocode:
randomPixelColors( array[RED,GREEN]); (2 colors so modulo is 2)
randomPixelColors( array[RED,YELLOW,GREEN]); (3 colors so modulo is 3)
The function will not know the length of the array unless you end every array with a known value that will never occur earlier in the array (or pass in the length). There are macros for having a variable number of arguments but I have never used them so I cannot be of much help.
Another way would be to define functions with one, two, three, and four arguments. They may all have the same name and the compiler will choose the right one based on the number (and type) of the arguments.