This commit is contained in:
Alex
2021-02-03 23:34:17 +03:00
parent 9be9c966d7
commit 3439e5cd3d
193 changed files with 35322 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#ifndef FastRandom_h
#define FastRandom_h
#include <Arduino.h>
class FastRandom {
public:
// установить сид
void setSeed(uint16_t seed) {
_seed = seed;
}
uint16_t get() {
_seed = (_seed * 2053ul) + 13849;
return _seed;
}
uint16_t get(uint16_t max) {
return ((uint32_t)max * get()) >> 16;
}
uint16_t get(uint16_t min, uint16_t max) {
return (get(max - min) + min);
}
private:
uint16_t _seed;
};
#endif