From e2f73d62df6e7b79483b571cd744701e233cf94a Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 23 Jun 2018 02:10:12 -0600 Subject: Moved pseudo_rand() into its own header, and made it gather entropy from ADC readings to improve randomness. Adjusted candle mode to use lower bits instead of upper bits, because the lower bits are more random. (also, the lower-bit method is slightly smaller in ROM) --- spaghetti-monster/fsm-adc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'spaghetti-monster/fsm-adc.c') diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index 6e9f19b..2ec630c 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -109,6 +109,11 @@ ISR(ADC_vect) { uint16_t measurement = ADC; // latest 10-bit ADC reading + #ifdef USE_PSEUDO_RAND + // real-world entropy makes this a true random, not pseudo + pseudo_rand_seed += measurement; + #endif + adc_step = (adc_step + 1) & (ADC_STEPS-1); #ifdef USE_LVP -- cgit v1.2.3