wallart/picker.cpp

16 lines
297 B
C++
Raw Permalink Normal View History

#include <Arduino.h>
#include <stdint.h>
#include "picker.h"
Picker::Picker() {
2024-06-09 21:53:19 -06:00
this->val = random(1, 256);
}
bool Picker::Pick(uint8_t likelihood) {
2024-06-09 21:53:19 -06:00
bool picked = false;
if ((val > 0) && (val <= likelihood)) {
2024-06-09 21:53:19 -06:00
picked = true;
}
val -= likelihood;
2024-06-09 21:53:19 -06:00
return picked;
}