Skip to content

Commit

Permalink
Use HW random
Browse files Browse the repository at this point in the history
  • Loading branch information
steadramon committed Aug 4, 2024
1 parent af8816b commit df0ca17
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ESPGeiger/src/GeigerInput/GeigerInputTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ void GeigerInputTest::begin() {

double GeigerInputTest::generatePoissonRand(double lambda) {
// https://tomroelandts.com/articles/simulating-a-geiger-counter
double u;
u = random(RAND_MAX) * 1.0 / RAND_MAX;
return -log(1 - u) / lambda;
double u;
#ifdef ESP8266
u = (1.0 * RANDOM_REG32) / 0xFFFFFFFF;
#else
u = (1.0 * esp_random()) / 0xFFFFFFFF;
#endif
return -log(1 - u) / lambda;
}

double GeigerInputTest::calcDelay() {
Expand Down

0 comments on commit df0ca17

Please sign in to comment.