mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-07 00:13:59 -04:00
AP_Math: added get_random16()
This commit is contained in:
parent
cd57422eed
commit
a8d10e8c2c
@ -174,3 +174,17 @@ template int constrain_value<int>(const int amt, const int low, const int high);
|
||||
template short constrain_value<short>(const short amt, const short low, const short high);
|
||||
template float constrain_value<float>(const float amt, const float low, const float high);
|
||||
template double constrain_value<double>(const double amt, const double low, const double high);
|
||||
|
||||
|
||||
/*
|
||||
simple 16 bit random number generator
|
||||
*/
|
||||
uint16_t get_random16(void)
|
||||
{
|
||||
static uint32_t m_z = 1234;
|
||||
static uint32_t m_w = 76542;
|
||||
m_z = 36969 * (m_z & 65535) + (m_z >> 16);
|
||||
m_w = 18000 * (m_w & 65535) + (m_w >> 16);
|
||||
return ((m_z << 16) + m_w) & 0xFFFF;
|
||||
}
|
||||
|
||||
|
@ -212,3 +212,7 @@ inline uint32_t usec_to_hz(uint32_t usec)
|
||||
float linear_interpolate(float low_output, float high_output,
|
||||
float var_value,
|
||||
float var_low, float var_high);
|
||||
|
||||
/* simple 16 bit random number generator */
|
||||
uint16_t get_random16(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user