1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-12 16:22:22 +01:00

Clean-up random helper functions (#3022)

This commit is contained in:
Oxan van Leeuwen
2022-01-10 01:50:26 +01:00
committed by GitHub
parent e55bd1e559
commit 6383eca54a
4 changed files with 40 additions and 61 deletions

View File

@@ -78,25 +78,6 @@ template<typename T, typename... Args> std::unique_ptr<T> make_unique(Args &&...
}
#endif
/// Return a random 32 bit unsigned integer.
uint32_t random_uint32();
/** Returns a random double between 0 and 1.
*
* Note: This function probably doesn't provide a truly uniform distribution.
*/
double random_double();
/// Returns a random float between 0 and 1. Essentially just casts random_double() to a float.
float random_float();
void fill_random(uint8_t *data, size_t len);
void fast_random_set_seed(uint32_t seed);
uint32_t fast_random_32();
uint16_t fast_random_16();
uint8_t fast_random_8();
/// Applies gamma correction with the provided gamma to value.
float gamma_correct(float value, float gamma);
/// Reverts gamma correction with the provided gamma to value.
@@ -304,6 +285,18 @@ constexpr uint64_t byteswap(uint64_t n) { return __builtin_bswap64(n); }
///@}
/// @name Mathematics
///@{
/// Return a random 32-bit unsigned integer.
uint32_t random_uint32();
/// Return a random float between 0 and 1.
float random_float();
/// Generate \p len number of random bytes.
void random_bytes(uint8_t *data, size_t len);
///@}
/// @name Bit manipulation
///@{