Skip to content

Commit

Permalink
Merge branch 'TimeOut-für-das-Adminmenü-by-Thomas-Lehnert' into DEV (…
Browse files Browse the repository at this point in the history
…pr xfjx/73)

This is mostly pull request xfjx#73 for upstream.
The formatting was modified to minimize the differences to the DEV branch
and the timeout check takes care of an millis() overflow. This overflow
happens every 50 days.
  • Loading branch information
tenbaht committed Nov 20, 2020
2 parents b34a3c4 + 4f25a7d commit 90a8590
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions Tonuino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1432,22 +1432,38 @@ uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
Serial.print(F("=== voiceMenu() ("));
Serial.print(numberOfOptions);
Serial.println(F(" Options)"));

// Vorgabe der AdmTimeOut Zeit in Millisekunden, die 5 ist die Zeit in Minuten:
unsigned long SollAdmTimeOut = 5*60000;
unsigned long AdmTimeOut = millis();

Serial.print(F("AdmTimeOut :"));
Serial.println(SollAdmTimeOut);
do {
//Serial.println((millis() - AdmTimeOut));
if((long)(millis() - AdmTimeOut) >= SollAdmTimeOut) {
Serial.println(F("TimeOut"));
mp3.playMp3FolderTrack(802); //802- "OK, ich habe den Vorgang abgebrochen.
//ignorePauseButton = true;
setstandbyTimer();
return defaultValue;
}
if (Serial.available() > 0) {
int optionSerial = Serial.parseInt();
if (optionSerial != 0 && optionSerial <= numberOfOptions)
return optionSerial;
}
readButtons();
mp3.loop();
if (pauseButton.pressedFor(LONG_PRESS)) {
mp3.playMp3FolderTrack(802);
if (pauseButton.pressedFor(LONG_PRESS)) { // Abbruch
mp3.playMp3FolderTrack(802); //802- "OK, ich habe den Vorgang abgebrochen.
ignorePauseButton = true;
checkStandbyAtMillis();
setstandbyTimer();
return defaultValue;
}
if (pauseButton.wasReleased()) {
if (returnValue != 0) {
AdmTimeOut = millis();
Serial.print(F("=== "));
Serial.print(returnValue);
Serial.println(F(" ==="));
Expand All @@ -1457,23 +1473,27 @@ uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
}

if (upButton.pressedFor(LONG_PRESS)) {
returnValue = min(returnValue + 10, numberOfOptions);
AdmTimeOut = millis();
returnValue = min(returnValue + 10, numberOfOptions); // 10 Schritte hoch
Serial.println(returnValue);
//mp3.pause();
mp3.pause();
mp3.playMp3FolderTrack(messageOffset + returnValue);
waitForTrackToFinish();
/*if (preview) {

//************preview 10-er Schritt** vorwärts **************
if (preview) {
if (previewFromFolder == 0)
mp3.playFolderTrack(returnValue, 1);
else
mp3.playFolderTrack(previewFromFolder, returnValue);
}*/
}
ignoreUpButton = true;
} else if (upButton.wasReleased()) {
AdmTimeOut = millis();
if (!ignoreUpButton) {
returnValue = min(returnValue + 1, numberOfOptions);
Serial.println(returnValue);
//mp3.pause();
mp3.pause();
mp3.playMp3FolderTrack(messageOffset + returnValue);
if (preview) {
waitForTrackToFinish();
Expand All @@ -1490,23 +1510,28 @@ uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
}

if (downButton.pressedFor(LONG_PRESS)) {
returnValue = max(returnValue - 10, 1);
AdmTimeOut = millis();
returnValue = max(returnValue - 10, 1); // 10 Schritte zurück
Serial.println(returnValue);
//mp3.pause();
mp3.pause();
mp3.playMp3FolderTrack(messageOffset + returnValue);
waitForTrackToFinish();
/*if (preview) {

//************preview 10-er Schritt* zurück ***************

if (preview) {
if (previewFromFolder == 0)
mp3.playFolderTrack(returnValue, 1);
else
mp3.playFolderTrack(previewFromFolder, returnValue);
}*/
}
ignoreDownButton = true;
} else if (downButton.wasReleased()) {
AdmTimeOut = millis();
if (!ignoreDownButton) {
returnValue = max(returnValue - 1, 1);
Serial.println(returnValue);
//mp3.pause();
mp3.pause();
mp3.playMp3FolderTrack(messageOffset + returnValue);
if (preview) {
waitForTrackToFinish();
Expand Down

0 comments on commit 90a8590

Please sign in to comment.