mirror of
https://github.com/xfjx/TonUINO.git
synced 2025-08-30 12:00:20 +02:00
Merge pull request #33 from mhioz/DEV
Initialisierung des Zufallsgenerators verbessert
This commit is contained in:
14
Tonuino.ino
14
Tonuino.ino
@@ -641,6 +641,7 @@ MFRC522::StatusCode status;
|
||||
#define buttonDown A2
|
||||
#define busyPin 4
|
||||
#define shutdownPin 7
|
||||
#define openAnalogPin A7
|
||||
|
||||
#ifdef FIVEBUTTONS
|
||||
#define buttonFourPin A3
|
||||
@@ -718,7 +719,15 @@ void waitForTrackToFinish() {
|
||||
void setup() {
|
||||
|
||||
Serial.begin(115200); // Es gibt ein paar Debug Ausgaben über die serielle Schnittstelle
|
||||
randomSeed(analogRead(A7)); // Zufallsgenerator initialisieren
|
||||
|
||||
// Wert für randomSeed() erzeugen durch das mehrfache Sammeln von rauschenden LSBs eines offenen Analogeingangs
|
||||
uint32_t ADC_LSB;
|
||||
uint32_t ADCSeed;
|
||||
for(uint8_t i = 0; i < 128; i++) {
|
||||
ADC_LSB = analogRead(openAnalogPin) & 0x1;
|
||||
ADCSeed ^= ADC_LSB << (i % 32);
|
||||
}
|
||||
randomSeed(ADCSeed); // Zufallsgenerator initialisieren
|
||||
|
||||
// Dieser Hinweis darf nicht entfernt werden
|
||||
Serial.println(F("\n _____ _____ _____ _____ _____"));
|
||||
@@ -840,7 +849,6 @@ void previousButton() {
|
||||
void playFolder() {
|
||||
Serial.println(F("== playFolder()")) ;
|
||||
disablestandbyTimer();
|
||||
randomSeed(millis() + random(1000));
|
||||
knownCard = true;
|
||||
_lastTrackFinished = 0;
|
||||
numTracksInFolder = mp3.getFolderTrackCount(myFolder->folder);
|
||||
@@ -1088,8 +1096,6 @@ void loop() {
|
||||
return;
|
||||
|
||||
if (readCard(&myCard) == true) {
|
||||
// make random a little bit more "random"
|
||||
randomSeed(millis() + random(1000));
|
||||
if (myCard.cookie == cardCookie && myCard.nfcFolderSettings.folder != 0 && myCard.nfcFolderSettings.mode != 0) {
|
||||
playFolder();
|
||||
}
|
||||
|
Reference in New Issue
Block a user