after find out about the very be-au-ti-ful fill_rainbow… i have scoured the code and found this little geeky gem!
what’s it do?
#define RAND16_SEED 1337
after find out about the very be-au-ti-ful fill_rainbow… i have scoured the code and found this little geeky gem!
what’s it do?
#define RAND16_SEED 1337
That’s just the initial seed value for the (fast) random number generator that’s in the library, which you use like this:
// fast 8 bit random number
byte r = random8( min, max);
// returns a number >= min and < max
// fast 16 bit random number
uint16_t i = random16( min, max);
// returns a number >= min and < max
Our random number generator is much faster than the built in Arduino “random” function, but it isn’t quite as random. I recommend that after every few hundred calls to random8 or random16, you add some extra entropy (randomness) to the seed. You can use the Arduino random function as a source of entropy of you wish:
random16_add_entropy( random() );
Since you don’t have to do this frequently (ie, only after every few hundred calls to random8/random16), the speed hit you’ll take from calling the Arduino “random” function isn’t too bad.