Fast 8-bit and 16-bit unsigned random number generators.
Significantly faster than Arduino random(), but also somewhat less random. You can add entropy.
Pseudo-random number generation follows the form:
X(n+1) = (2053 * X(n)) + 13849)
uint16_t | rand16seed |
| Seed for the random number generator functions.
|
|
LIB8STATIC uint8_t | random8 () |
| Generate an 8-bit random number.
|
|
LIB8STATIC uint16_t | random16 () |
| Generate a 16-bit random number.
|
|
LIB8STATIC uint8_t | random8 (uint8_t lim) |
| Generate an 8-bit random number between 0 and lim.
|
|
LIB8STATIC uint8_t | random8 (uint8_t min, uint8_t lim) |
| Generate an 8-bit random number in the given range.
|
|
LIB8STATIC uint16_t | random16 (uint16_t lim) |
| Generate an 16-bit random number between 0 and lim.
|
|
LIB8STATIC uint16_t | random16 (uint16_t min, uint16_t lim) |
| Generate an 16-bit random number in the given range.
|
|
LIB8STATIC void | random16_set_seed (uint16_t seed) |
| Set the 16-bit seed used for the random number generator.
|
|
LIB8STATIC uint16_t | random16_get_seed () |
| Get the current seed value for the random number generator.
|
|
LIB8STATIC void | random16_add_entropy (uint16_t entropy) |
| Add entropy into the random number generator.
|
|
#define | FASTLED_RAND16_2053 ((uint16_t)(2053)) |
| Multiplier value for pseudo-random number generation.
|
|
#define | FASTLED_RAND16_13849 ((uint16_t)(13849)) |
| Increment value for pseudo-random number generation.
|
|
#define | APPLY_FASTLED_RAND16_2053(x) (x * FASTLED_RAND16_2053) |
| Multiplies a value by the pseudo-random multiplier.
|
|
◆ APPLY_FASTLED_RAND16_2053
Multiplies a value by the pseudo-random multiplier.
Definition at line 32 of file random8.h.
◆ FASTLED_RAND16_13849
#define FASTLED_RAND16_13849 ((uint16_t)(13849)) |
Increment value for pseudo-random number generation.
Definition at line 25 of file random8.h.
◆ FASTLED_RAND16_2053
#define FASTLED_RAND16_2053 ((uint16_t)(2053)) |
Multiplier value for pseudo-random number generation.
Definition at line 23 of file random8.h.
◆ random16() [1/3]
LIB8STATIC uint16_t random16 |
( |
| ) |
|
◆ random16() [2/3]
LIB8STATIC uint16_t random16 |
( |
uint16_t | lim | ) |
|
Generate an 16-bit random number between 0 and lim.
- Parameters
-
lim | the upper bound for the result, exclusive |
Definition at line 74 of file random8.h.
◆ random16() [3/3]
LIB8STATIC uint16_t random16 |
( |
uint16_t | min, |
|
|
uint16_t | lim ) |
Generate an 16-bit random number in the given range.
- Parameters
-
min | the lower bound for the random number, inclusive |
lim | the upper bound for the random number, exclusive |
Definition at line 84 of file random8.h.
◆ random16_add_entropy()
LIB8STATIC void random16_add_entropy |
( |
uint16_t | entropy | ) |
|
◆ random16_get_seed()
LIB8STATIC uint16_t random16_get_seed |
( |
| ) |
|
Get the current seed value for the random number generator.
Definition at line 94 of file random8.h.
◆ random16_set_seed()
LIB8STATIC void random16_set_seed |
( |
uint16_t | seed | ) |
|
◆ random8() [1/3]
LIB8STATIC uint8_t random8 |
( |
| ) |
|
◆ random8() [2/3]
LIB8STATIC uint8_t random8 |
( |
uint8_t | lim | ) |
|
Generate an 8-bit random number between 0 and lim.
- Parameters
-
lim | the upper bound for the result, exclusive |
Definition at line 57 of file random8.h.
◆ random8() [3/3]
LIB8STATIC uint8_t random8 |
( |
uint8_t | min, |
|
|
uint8_t | lim ) |
Generate an 8-bit random number in the given range.
- Parameters
-
min | the lower bound for the random number, inclusive |
lim | the upper bound for the random number, exclusive |
Definition at line 66 of file random8.h.
◆ rand16seed
Seed for the random number generator functions.
Definition at line 17 of file lib8tion.cpp.