feat(lv_math): add lv_rand_set_seed api (#5013)
This commit is contained in:
@@ -87,7 +87,7 @@ static inline void lv_global_init(lv_global_t * global)
|
|||||||
global->style_last_custom_prop_id = (uint32_t)_LV_STYLE_LAST_BUILT_IN_PROP;
|
global->style_last_custom_prop_id = (uint32_t)_LV_STYLE_LAST_BUILT_IN_PROP;
|
||||||
global->area_trans_cache.angle_prev = INT32_MIN;
|
global->area_trans_cache.angle_prev = INT32_MIN;
|
||||||
global->event_last_register_id = _LV_EVENT_LAST;
|
global->event_last_register_id = _LV_EVENT_LAST;
|
||||||
global->math_rand_seed = 0x1234ABCD;
|
lv_rand_set_seed(0x1234ABCD);
|
||||||
|
|
||||||
#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0
|
#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0
|
||||||
global->sw_shadow_cache.cache_size = -1;
|
global->sw_shadow_cache.cache_size = -1;
|
||||||
|
|||||||
@@ -333,6 +333,11 @@ int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32
|
|||||||
return ((x - min_in) * delta_out) / delta_in + min_out;
|
return ((x - min_in) * delta_out) / delta_in + min_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lv_rand_set_seed(uint32_t seed)
|
||||||
|
{
|
||||||
|
rand_seed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t lv_rand(uint32_t min, uint32_t max)
|
uint32_t lv_rand(uint32_t min, uint32_t max)
|
||||||
{
|
{
|
||||||
/*Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs"*/
|
/*Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs"*/
|
||||||
|
|||||||
@@ -125,6 +125,12 @@ int64_t lv_pow(int64_t base, int8_t exp);
|
|||||||
*/
|
*/
|
||||||
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out);
|
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the seed of the pseudo random number generator
|
||||||
|
* @param seed a number to initialize the random generator
|
||||||
|
*/
|
||||||
|
void lv_rand_set_seed(uint32_t seed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a pseudo random number in the given range
|
* Get a pseudo random number in the given range
|
||||||
* @param min the minimum value
|
* @param min the minimum value
|
||||||
|
|||||||
Reference in New Issue
Block a user