1
0
mirror of https://github.com/xfjx/TonUINO.git synced 2025-08-27 14:20:03 +02:00

Der Standby Timer ist da!

This commit is contained in:
Thorsten Voß
2019-01-04 01:07:32 +01:00
parent 0e64f4a3c4
commit 3df71b2311
318 changed files with 102 additions and 53 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -4,6 +4,7 @@
#include <MFRC522.h> #include <MFRC522.h>
#include <SPI.h> #include <SPI.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include <avr/sleep.h>
// DFPlayer Mini // DFPlayer Mini
SoftwareSerial mySoftwareSerial(2, 3); // RX, TX SoftwareSerial mySoftwareSerial(2, 3); // RX, TX
@@ -122,8 +123,8 @@ void resetSettings() {
mySettings.initVolume = 15; mySettings.initVolume = 15;
mySettings.eq = 1; mySettings.eq = 1;
mySettings.locked = false; mySettings.locked = false;
mySettings.standbyTimer = 5; mySettings.standbyTimer = 0;
mySettings.invertVolumeButtons = false; mySettings.invertVolumeButtons = true;
mySettings.shortCuts[0].folder = 0; mySettings.shortCuts[0].folder = 0;
mySettings.shortCuts[1].folder = 0; mySettings.shortCuts[1].folder = 0;
mySettings.shortCuts[2].folder = 0; mySettings.shortCuts[2].folder = 0;
@@ -168,29 +169,6 @@ void loadSettingsFromFlash() {
Serial.println(mySettings.invertVolumeButtons); Serial.println(mySettings.invertVolumeButtons);
} }
/// Funktionen für den Standby Timer (z.B. über Pololu-Switch oder Mosfet)
void setstandbyTimer() {
Serial.println(F("=== setstandbyTimer()"));
if (mySettings.standbyTimer != 0)
sleepAtMillis = millis() + (mySettings.standbyTimer * 1000);
else
sleepAtMillis = 0;
Serial.println(sleepAtMillis);
}
void disablestandbyTimer() {
Serial.println(F("=== disablestandby()"));
sleepAtMillis = 0;
}
void checkStandbyAtMillis() {
if (sleepAtMillis != 0 && millis() > sleepAtMillis) {
// enter sleep state
}
}
// Leider kann das Modul selbst keine Queue abspielen, daher müssen wir selbst die Queue verwalten // Leider kann das Modul selbst keine Queue abspielen, daher müssen wir selbst die Queue verwalten
static uint16_t _lastTrackFinished; static uint16_t _lastTrackFinished;
static void nextTrack(uint16_t track) { static void nextTrack(uint16_t track) {
@@ -316,6 +294,7 @@ MFRC522::StatusCode status;
#define buttonUp A1 #define buttonUp A1
#define buttonDown A2 #define buttonDown A2
#define busyPin 4 #define busyPin 4
#define shutdownPin 8
#define LONG_PRESS 1000 #define LONG_PRESS 1000
@@ -326,6 +305,41 @@ bool ignorePauseButton = false;
bool ignoreUpButton = false; bool ignoreUpButton = false;
bool ignoreDownButton = false; bool ignoreDownButton = false;
/// Funktionen für den Standby Timer (z.B. über Pololu-Switch oder Mosfet)
void setstandbyTimer() {
Serial.println(F("=== setstandbyTimer()"));
if (mySettings.standbyTimer != 0)
sleepAtMillis = millis() + (mySettings.standbyTimer * 60 * 1000);
else
sleepAtMillis = 0;
Serial.println(sleepAtMillis);
}
void disablestandbyTimer() {
Serial.println(F("=== disablestandby()"));
sleepAtMillis = 0;
}
void checkStandbyAtMillis() {
if (sleepAtMillis != 0 && millis() > sleepAtMillis) {
Serial.println(F("=== power off!"));
// enter sleep state
// http://discourse.voss.earth/t/intenso-s10000-powerbank-automatische-abschaltung-software-only/805
// powerdown to 27mA (powerbank switches off after 30-60s)
mfrc522.PCD_AntennaOff();
mfrc522.PCD_SoftPowerDown();
mp3.sleep();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
cli(); // Disable interrupts
sleep_mode();
}
}
bool isPlaying() { bool isPlaying() {
return !digitalRead(busyPin); return !digitalRead(busyPin);
} }
@@ -524,6 +538,7 @@ void playShortCut(uint8_t shortCut) {
void loop() { void loop() {
do { do {
checkStandbyAtMillis();
mp3.loop(); mp3.loop();
// Buttons werden nun über JS_Button gehandelt, dadurch kann jede Taste // Buttons werden nun über JS_Button gehandelt, dadurch kann jede Taste
// doppelt belegt werden // doppelt belegt werden
@@ -555,56 +570,70 @@ void loop() {
ignorePauseButton == false) { ignorePauseButton == false) {
if (isPlaying()) { if (isPlaying()) {
uint8_t advertTrack; uint8_t advertTrack;
if (myFolder->mode == 3 || myFolder->mode == 9) if (myFolder->mode == 3 || myFolder->mode == 9) {
advertTrack = (queue[currentTrack - 1]); advertTrack = (queue[currentTrack - 1]);
else }
else {
advertTrack = currentTrack; advertTrack = currentTrack;
}
// Spezialmodus Von-Bis für Album und Party gibt die Dateinummer relativ zur Startposition wieder // Spezialmodus Von-Bis für Album und Party gibt die Dateinummer relativ zur Startposition wieder
if (myFolder->mode == 8 || myFolder->mode == 9) if (myFolder->mode == 8 || myFolder->mode == 9) {
advertTrack = advertTrack - myFolder->special + 1; advertTrack = advertTrack - myFolder->special + 1;
}
mp3.playAdvertisement(advertTrack); mp3.playAdvertisement(advertTrack);
} }
else else {
playShortCut(0); playShortCut(0);
}
ignorePauseButton = true; ignorePauseButton = true;
} }
if (upButton.pressedFor(LONG_PRESS)) { if (upButton.pressedFor(LONG_PRESS)) {
if (isPlaying()) { if (isPlaying()) {
if (!mySettings.invertVolumeButtons) if (!mySettings.invertVolumeButtons) {
volumeUpButton(); volumeUpButton();
else }
else {
nextButton(); nextButton();
}
ignoreUpButton = true; ignoreUpButton = true;
} }
else else {
playShortCut(1); playShortCut(1);
}
} else if (upButton.wasReleased()) { } else if (upButton.wasReleased()) {
if (!ignoreUpButton) if (!ignoreUpButton)
if (!mySettings.invertVolumeButtons) if (!mySettings.invertVolumeButtons) {
nextButton(); nextButton();
else }
else {
volumeUpButton(); volumeUpButton();
}
ignoreUpButton = false; ignoreUpButton = false;
} }
if (downButton.pressedFor(LONG_PRESS)) { if (downButton.pressedFor(LONG_PRESS)) {
if (isPlaying()) { if (isPlaying()) {
if (!mySettings.invertVolumeButtons) if (!mySettings.invertVolumeButtons) {
volumeDownButton(); volumeDownButton();
else }
else {
previousButton(); previousButton();
}
ignoreDownButton = true; ignoreDownButton = true;
} }
else else {
playShortCut(2); playShortCut(2);
}
} else if (downButton.wasReleased()) { } else if (downButton.wasReleased()) {
if (!ignoreDownButton) if (!ignoreDownButton) {
if (!mySettings.invertVolumeButtons) if (!mySettings.invertVolumeButtons) {
previousButton(); previousButton();
else }
else {
volumeDownButton(); volumeDownButton();
}
}
ignoreDownButton = false; ignoreDownButton = false;
} }
// Ende der Buttons // Ende der Buttons
@@ -646,18 +675,22 @@ void adminMenu() {
mfrc522.PICC_HaltA(); mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1(); mfrc522.PCD_StopCrypto1();
} }
else if (subMenu == 2) else if (subMenu == 2) {
// Maximum Volume // Maximum Volume
mySettings.maxVolume = voiceMenu(30, 930, 0, false, false, mySettings.maxVolume); mySettings.maxVolume = voiceMenu(30, 930, 0, false, false, mySettings.maxVolume);
else if (subMenu == 3) }
else if (subMenu == 3) {
// Minimum Volume // Minimum Volume
mySettings.minVolume = voiceMenu(30, 931, 0, false, false, mySettings.minVolume); mySettings.minVolume = voiceMenu(30, 931, 0, false, false, mySettings.minVolume);
else if (subMenu == 4) }
else if (subMenu == 4) {
// Initial Volume // Initial Volume
mySettings.initVolume = voiceMenu(30, 932, 0, false, false, mySettings.initVolume); mySettings.initVolume = voiceMenu(30, 932, 0, false, false, mySettings.initVolume);
else if (subMenu == 5) }
else if (subMenu == 5) {
// EQ // EQ
mySettings.eq = voiceMenu(6, 920, 920, false, false, mySettings.eq); mySettings.eq = voiceMenu(6, 920, 920, false, false, mySettings.eq);
}
else if (subMenu == 6) { else if (subMenu == 6) {
// create master card // create master card
} }
@@ -667,7 +700,13 @@ void adminMenu() {
mp3.playMp3FolderTrack(400); mp3.playMp3FolderTrack(400);
} }
else if (subMenu == 8) { else if (subMenu == 8) {
// Den Standbytimer konfigurieren switch (voiceMenu(5, 960, 960)) {
case 1: mySettings.standbyTimer = 5; break;
case 2: mySettings.standbyTimer = 15; break;
case 3: mySettings.standbyTimer = 30; break;
case 4: mySettings.standbyTimer = 60; break;
case 5: mySettings.standbyTimer = 0; break;
}
} }
else if (subMenu == 9) { else if (subMenu == 9) {
// Create Cards for Folder // Create Cards for Folder
@@ -712,10 +751,12 @@ void adminMenu() {
else if (subMenu == 10) { else if (subMenu == 10) {
// Invert Functions for Up/Down Buttons // Invert Functions for Up/Down Buttons
int temp = voiceMenu(2, 933, 933, false); int temp = voiceMenu(2, 933, 933, false);
if (temp == 2) if (temp == 2) {
mySettings.invertVolumeButtons = true; mySettings.invertVolumeButtons = true;
else }
else {
mySettings.invertVolumeButtons = false; mySettings.invertVolumeButtons = false;
}
} }
writeSettingsToFlash(); writeSettingsToFlash();
setstandbyTimer(); setstandbyTimer();
@@ -773,14 +814,16 @@ uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
mp3.playMp3FolderTrack(messageOffset + returnValue); mp3.playMp3FolderTrack(messageOffset + returnValue);
if (preview) { if (preview) {
waitForTrackToFinish(); waitForTrackToFinish();
if (previewFromFolder == 0) if (previewFromFolder == 0) {
mp3.playFolderTrack(returnValue, 1); mp3.playFolderTrack(returnValue, 1);
else } else {
mp3.playFolderTrack(previewFromFolder, returnValue); mp3.playFolderTrack(previewFromFolder, returnValue);
}
delay(1000); delay(1000);
} }
} else } else {
ignoreUpButton = false; ignoreUpButton = false;
}
} }
if (downButton.pressedFor(LONG_PRESS)) { if (downButton.pressedFor(LONG_PRESS)) {
@@ -810,8 +853,9 @@ uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
mp3.playFolderTrack(previewFromFolder, returnValue); mp3.playFolderTrack(previewFromFolder, returnValue);
delay(1000); delay(1000);
} }
} else } else {
ignoreDownButton = false; ignoreDownButton = false;
}
} }
} while (true); } while (true);
} }

BIN
mp3/0001.mp3 Normal file

Binary file not shown.

BIN
mp3/0002.mp3 Normal file

Binary file not shown.

BIN
mp3/0003.mp3 Normal file

Binary file not shown.

BIN
mp3/0004.mp3 Normal file

Binary file not shown.

BIN
mp3/0005.mp3 Normal file

Binary file not shown.

BIN
mp3/0006.mp3 Normal file

Binary file not shown.

BIN
mp3/0007.mp3 Normal file

Binary file not shown.

BIN
mp3/0008.mp3 Normal file

Binary file not shown.

BIN
mp3/0009.mp3 Normal file

Binary file not shown.

BIN
mp3/0010.mp3 Normal file

Binary file not shown.

BIN
mp3/0011.mp3 Normal file

Binary file not shown.

BIN
mp3/0012.mp3 Normal file

Binary file not shown.

BIN
mp3/0013.mp3 Normal file

Binary file not shown.

BIN
mp3/0014.mp3 Normal file

Binary file not shown.

BIN
mp3/0015.mp3 Normal file

Binary file not shown.

BIN
mp3/0016.mp3 Normal file

Binary file not shown.

BIN
mp3/0017.mp3 Normal file

Binary file not shown.

BIN
mp3/0018.mp3 Normal file

Binary file not shown.

BIN
mp3/0019.mp3 Normal file

Binary file not shown.

BIN
mp3/0020.mp3 Normal file

Binary file not shown.

BIN
mp3/0021.mp3 Normal file

Binary file not shown.

BIN
mp3/0022.mp3 Normal file

Binary file not shown.

BIN
mp3/0023.mp3 Normal file

Binary file not shown.

BIN
mp3/0024.mp3 Normal file

Binary file not shown.

BIN
mp3/0025.mp3 Normal file

Binary file not shown.

BIN
mp3/0026.mp3 Normal file

Binary file not shown.

BIN
mp3/0027.mp3 Normal file

Binary file not shown.

BIN
mp3/0028.mp3 Normal file

Binary file not shown.

BIN
mp3/0029.mp3 Normal file

Binary file not shown.

BIN
mp3/0030.mp3 Normal file

Binary file not shown.

BIN
mp3/0031.mp3 Normal file

Binary file not shown.

BIN
mp3/0032.mp3 Normal file

Binary file not shown.

BIN
mp3/0033.mp3 Normal file

Binary file not shown.

BIN
mp3/0034.mp3 Normal file

Binary file not shown.

BIN
mp3/0035.mp3 Normal file

Binary file not shown.

BIN
mp3/0036.mp3 Normal file

Binary file not shown.

BIN
mp3/0037.mp3 Normal file

Binary file not shown.

BIN
mp3/0038.mp3 Normal file

Binary file not shown.

BIN
mp3/0039.mp3 Normal file

Binary file not shown.

BIN
mp3/0040.mp3 Normal file

Binary file not shown.

BIN
mp3/0041.mp3 Normal file

Binary file not shown.

BIN
mp3/0042.mp3 Normal file

Binary file not shown.

BIN
mp3/0043.mp3 Normal file

Binary file not shown.

BIN
mp3/0044.mp3 Normal file

Binary file not shown.

BIN
mp3/0045.mp3 Normal file

Binary file not shown.

BIN
mp3/0046.mp3 Normal file

Binary file not shown.

BIN
mp3/0047.mp3 Normal file

Binary file not shown.

BIN
mp3/0048.mp3 Normal file

Binary file not shown.

BIN
mp3/0049.mp3 Normal file

Binary file not shown.

BIN
mp3/0050.mp3 Normal file

Binary file not shown.

BIN
mp3/0051.mp3 Normal file

Binary file not shown.

BIN
mp3/0052.mp3 Normal file

Binary file not shown.

BIN
mp3/0053.mp3 Normal file

Binary file not shown.

BIN
mp3/0054.mp3 Normal file

Binary file not shown.

BIN
mp3/0055.mp3 Normal file

Binary file not shown.

BIN
mp3/0056.mp3 Normal file

Binary file not shown.

BIN
mp3/0057.mp3 Normal file

Binary file not shown.

BIN
mp3/0058.mp3 Normal file

Binary file not shown.

BIN
mp3/0059.mp3 Normal file

Binary file not shown.

BIN
mp3/0060.mp3 Normal file

Binary file not shown.

BIN
mp3/0061.mp3 Normal file

Binary file not shown.

BIN
mp3/0062.mp3 Normal file

Binary file not shown.

BIN
mp3/0063.mp3 Normal file

Binary file not shown.

BIN
mp3/0064.mp3 Normal file

Binary file not shown.

BIN
mp3/0065.mp3 Normal file

Binary file not shown.

BIN
mp3/0066.mp3 Normal file

Binary file not shown.

BIN
mp3/0067.mp3 Normal file

Binary file not shown.

BIN
mp3/0068.mp3 Normal file

Binary file not shown.

BIN
mp3/0069.mp3 Normal file

Binary file not shown.

BIN
mp3/0070.mp3 Normal file

Binary file not shown.

BIN
mp3/0071.mp3 Normal file

Binary file not shown.

BIN
mp3/0072.mp3 Normal file

Binary file not shown.

BIN
mp3/0073.mp3 Normal file

Binary file not shown.

BIN
mp3/0074.mp3 Normal file

Binary file not shown.

BIN
mp3/0075.mp3 Normal file

Binary file not shown.

BIN
mp3/0076.mp3 Normal file

Binary file not shown.

BIN
mp3/0077.mp3 Normal file

Binary file not shown.

BIN
mp3/0078.mp3 Normal file

Binary file not shown.

BIN
mp3/0079.mp3 Normal file

Binary file not shown.

BIN
mp3/0080.mp3 Normal file

Binary file not shown.

BIN
mp3/0081.mp3 Normal file

Binary file not shown.

BIN
mp3/0082.mp3 Normal file

Binary file not shown.

BIN
mp3/0083.mp3 Normal file

Binary file not shown.

BIN
mp3/0084.mp3 Normal file

Binary file not shown.

BIN
mp3/0085.mp3 Normal file

Binary file not shown.

BIN
mp3/0086.mp3 Normal file

Binary file not shown.

BIN
mp3/0087.mp3 Normal file

Binary file not shown.

BIN
mp3/0088.mp3 Normal file

Binary file not shown.

BIN
mp3/0089.mp3 Normal file

Binary file not shown.

BIN
mp3/0090.mp3 Normal file

Binary file not shown.

BIN
mp3/0091.mp3 Normal file

Binary file not shown.

BIN
mp3/0092.mp3 Normal file

Binary file not shown.

BIN
mp3/0093.mp3 Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More