mirror of
https://github.com/xfjx/TonUINO.git
synced 2025-08-26 15:54:49 +02:00
Der Standby Timer ist da!
This commit is contained in:
BIN
SD-Karte/mp3/0960_timer_intro.mp3
Normal file
BIN
SD-Karte/mp3/0960_timer_intro.mp3
Normal file
Binary file not shown.
BIN
SD-Karte/mp3/0961_timer_5.mp3
Normal file
BIN
SD-Karte/mp3/0961_timer_5.mp3
Normal file
Binary file not shown.
BIN
SD-Karte/mp3/0962_timer_15.mp3
Normal file
BIN
SD-Karte/mp3/0962_timer_15.mp3
Normal file
Binary file not shown.
BIN
SD-Karte/mp3/0963_timer_30.mp3
Normal file
BIN
SD-Karte/mp3/0963_timer_30.mp3
Normal file
Binary file not shown.
BIN
SD-Karte/mp3/0964_timer_60.mp3
Normal file
BIN
SD-Karte/mp3/0964_timer_60.mp3
Normal file
Binary file not shown.
BIN
SD-Karte/mp3/0965_timer_disabled.mp3
Normal file
BIN
SD-Karte/mp3/0965_timer_disabled.mp3
Normal file
Binary file not shown.
148
Tonuino.ino
148
Tonuino.ino
@@ -4,6 +4,7 @@
|
||||
#include <MFRC522.h>
|
||||
#include <SPI.h>
|
||||
#include <SoftwareSerial.h>
|
||||
#include <avr/sleep.h>
|
||||
|
||||
// DFPlayer Mini
|
||||
SoftwareSerial mySoftwareSerial(2, 3); // RX, TX
|
||||
@@ -122,8 +123,8 @@ void resetSettings() {
|
||||
mySettings.initVolume = 15;
|
||||
mySettings.eq = 1;
|
||||
mySettings.locked = false;
|
||||
mySettings.standbyTimer = 5;
|
||||
mySettings.invertVolumeButtons = false;
|
||||
mySettings.standbyTimer = 0;
|
||||
mySettings.invertVolumeButtons = true;
|
||||
mySettings.shortCuts[0].folder = 0;
|
||||
mySettings.shortCuts[1].folder = 0;
|
||||
mySettings.shortCuts[2].folder = 0;
|
||||
@@ -168,29 +169,6 @@ void loadSettingsFromFlash() {
|
||||
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
|
||||
static uint16_t _lastTrackFinished;
|
||||
static void nextTrack(uint16_t track) {
|
||||
@@ -316,6 +294,7 @@ MFRC522::StatusCode status;
|
||||
#define buttonUp A1
|
||||
#define buttonDown A2
|
||||
#define busyPin 4
|
||||
#define shutdownPin 8
|
||||
|
||||
#define LONG_PRESS 1000
|
||||
|
||||
@@ -326,6 +305,41 @@ bool ignorePauseButton = false;
|
||||
bool ignoreUpButton = 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() {
|
||||
return !digitalRead(busyPin);
|
||||
}
|
||||
@@ -524,6 +538,7 @@ void playShortCut(uint8_t shortCut) {
|
||||
|
||||
void loop() {
|
||||
do {
|
||||
checkStandbyAtMillis();
|
||||
mp3.loop();
|
||||
// Buttons werden nun über JS_Button gehandelt, dadurch kann jede Taste
|
||||
// doppelt belegt werden
|
||||
@@ -555,56 +570,70 @@ void loop() {
|
||||
ignorePauseButton == false) {
|
||||
if (isPlaying()) {
|
||||
uint8_t advertTrack;
|
||||
if (myFolder->mode == 3 || myFolder->mode == 9)
|
||||
if (myFolder->mode == 3 || myFolder->mode == 9) {
|
||||
advertTrack = (queue[currentTrack - 1]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
advertTrack = currentTrack;
|
||||
}
|
||||
// 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;
|
||||
|
||||
}
|
||||
mp3.playAdvertisement(advertTrack);
|
||||
}
|
||||
else
|
||||
else {
|
||||
playShortCut(0);
|
||||
}
|
||||
ignorePauseButton = true;
|
||||
}
|
||||
|
||||
if (upButton.pressedFor(LONG_PRESS)) {
|
||||
if (isPlaying()) {
|
||||
if (!mySettings.invertVolumeButtons)
|
||||
if (!mySettings.invertVolumeButtons) {
|
||||
volumeUpButton();
|
||||
else
|
||||
}
|
||||
else {
|
||||
nextButton();
|
||||
}
|
||||
ignoreUpButton = true;
|
||||
}
|
||||
else
|
||||
else {
|
||||
playShortCut(1);
|
||||
}
|
||||
} else if (upButton.wasReleased()) {
|
||||
if (!ignoreUpButton)
|
||||
if (!mySettings.invertVolumeButtons)
|
||||
if (!mySettings.invertVolumeButtons) {
|
||||
nextButton();
|
||||
else
|
||||
}
|
||||
else {
|
||||
volumeUpButton();
|
||||
}
|
||||
ignoreUpButton = false;
|
||||
}
|
||||
|
||||
if (downButton.pressedFor(LONG_PRESS)) {
|
||||
if (isPlaying()) {
|
||||
if (!mySettings.invertVolumeButtons)
|
||||
if (!mySettings.invertVolumeButtons) {
|
||||
volumeDownButton();
|
||||
else
|
||||
}
|
||||
else {
|
||||
previousButton();
|
||||
}
|
||||
ignoreDownButton = true;
|
||||
}
|
||||
else
|
||||
else {
|
||||
playShortCut(2);
|
||||
}
|
||||
} else if (downButton.wasReleased()) {
|
||||
if (!ignoreDownButton)
|
||||
if (!mySettings.invertVolumeButtons)
|
||||
if (!ignoreDownButton) {
|
||||
if (!mySettings.invertVolumeButtons) {
|
||||
previousButton();
|
||||
else
|
||||
}
|
||||
else {
|
||||
volumeDownButton();
|
||||
}
|
||||
}
|
||||
ignoreDownButton = false;
|
||||
}
|
||||
// Ende der Buttons
|
||||
@@ -646,18 +675,22 @@ void adminMenu() {
|
||||
mfrc522.PICC_HaltA();
|
||||
mfrc522.PCD_StopCrypto1();
|
||||
}
|
||||
else if (subMenu == 2)
|
||||
else if (subMenu == 2) {
|
||||
// Maximum Volume
|
||||
mySettings.maxVolume = voiceMenu(30, 930, 0, false, false, mySettings.maxVolume);
|
||||
else if (subMenu == 3)
|
||||
}
|
||||
else if (subMenu == 3) {
|
||||
// Minimum Volume
|
||||
mySettings.minVolume = voiceMenu(30, 931, 0, false, false, mySettings.minVolume);
|
||||
else if (subMenu == 4)
|
||||
}
|
||||
else if (subMenu == 4) {
|
||||
// Initial Volume
|
||||
mySettings.initVolume = voiceMenu(30, 932, 0, false, false, mySettings.initVolume);
|
||||
else if (subMenu == 5)
|
||||
}
|
||||
else if (subMenu == 5) {
|
||||
// EQ
|
||||
mySettings.eq = voiceMenu(6, 920, 920, false, false, mySettings.eq);
|
||||
}
|
||||
else if (subMenu == 6) {
|
||||
// create master card
|
||||
}
|
||||
@@ -667,7 +700,13 @@ void adminMenu() {
|
||||
mp3.playMp3FolderTrack(400);
|
||||
}
|
||||
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) {
|
||||
// Create Cards for Folder
|
||||
@@ -712,10 +751,12 @@ void adminMenu() {
|
||||
else if (subMenu == 10) {
|
||||
// Invert Functions for Up/Down Buttons
|
||||
int temp = voiceMenu(2, 933, 933, false);
|
||||
if (temp == 2)
|
||||
if (temp == 2) {
|
||||
mySettings.invertVolumeButtons = true;
|
||||
else
|
||||
}
|
||||
else {
|
||||
mySettings.invertVolumeButtons = false;
|
||||
}
|
||||
}
|
||||
writeSettingsToFlash();
|
||||
setstandbyTimer();
|
||||
@@ -773,14 +814,16 @@ uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
|
||||
mp3.playMp3FolderTrack(messageOffset + returnValue);
|
||||
if (preview) {
|
||||
waitForTrackToFinish();
|
||||
if (previewFromFolder == 0)
|
||||
if (previewFromFolder == 0) {
|
||||
mp3.playFolderTrack(returnValue, 1);
|
||||
else
|
||||
} else {
|
||||
mp3.playFolderTrack(previewFromFolder, returnValue);
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
ignoreUpButton = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (downButton.pressedFor(LONG_PRESS)) {
|
||||
@@ -810,8 +853,9 @@ uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
|
||||
mp3.playFolderTrack(previewFromFolder, returnValue);
|
||||
delay(1000);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
ignoreDownButton = false;
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
BIN
mp3/0001.mp3
Normal file
BIN
mp3/0001.mp3
Normal file
Binary file not shown.
BIN
mp3/0002.mp3
Normal file
BIN
mp3/0002.mp3
Normal file
Binary file not shown.
BIN
mp3/0003.mp3
Normal file
BIN
mp3/0003.mp3
Normal file
Binary file not shown.
BIN
mp3/0004.mp3
Normal file
BIN
mp3/0004.mp3
Normal file
Binary file not shown.
BIN
mp3/0005.mp3
Normal file
BIN
mp3/0005.mp3
Normal file
Binary file not shown.
BIN
mp3/0006.mp3
Normal file
BIN
mp3/0006.mp3
Normal file
Binary file not shown.
BIN
mp3/0007.mp3
Normal file
BIN
mp3/0007.mp3
Normal file
Binary file not shown.
BIN
mp3/0008.mp3
Normal file
BIN
mp3/0008.mp3
Normal file
Binary file not shown.
BIN
mp3/0009.mp3
Normal file
BIN
mp3/0009.mp3
Normal file
Binary file not shown.
BIN
mp3/0010.mp3
Normal file
BIN
mp3/0010.mp3
Normal file
Binary file not shown.
BIN
mp3/0011.mp3
Normal file
BIN
mp3/0011.mp3
Normal file
Binary file not shown.
BIN
mp3/0012.mp3
Normal file
BIN
mp3/0012.mp3
Normal file
Binary file not shown.
BIN
mp3/0013.mp3
Normal file
BIN
mp3/0013.mp3
Normal file
Binary file not shown.
BIN
mp3/0014.mp3
Normal file
BIN
mp3/0014.mp3
Normal file
Binary file not shown.
BIN
mp3/0015.mp3
Normal file
BIN
mp3/0015.mp3
Normal file
Binary file not shown.
BIN
mp3/0016.mp3
Normal file
BIN
mp3/0016.mp3
Normal file
Binary file not shown.
BIN
mp3/0017.mp3
Normal file
BIN
mp3/0017.mp3
Normal file
Binary file not shown.
BIN
mp3/0018.mp3
Normal file
BIN
mp3/0018.mp3
Normal file
Binary file not shown.
BIN
mp3/0019.mp3
Normal file
BIN
mp3/0019.mp3
Normal file
Binary file not shown.
BIN
mp3/0020.mp3
Normal file
BIN
mp3/0020.mp3
Normal file
Binary file not shown.
BIN
mp3/0021.mp3
Normal file
BIN
mp3/0021.mp3
Normal file
Binary file not shown.
BIN
mp3/0022.mp3
Normal file
BIN
mp3/0022.mp3
Normal file
Binary file not shown.
BIN
mp3/0023.mp3
Normal file
BIN
mp3/0023.mp3
Normal file
Binary file not shown.
BIN
mp3/0024.mp3
Normal file
BIN
mp3/0024.mp3
Normal file
Binary file not shown.
BIN
mp3/0025.mp3
Normal file
BIN
mp3/0025.mp3
Normal file
Binary file not shown.
BIN
mp3/0026.mp3
Normal file
BIN
mp3/0026.mp3
Normal file
Binary file not shown.
BIN
mp3/0027.mp3
Normal file
BIN
mp3/0027.mp3
Normal file
Binary file not shown.
BIN
mp3/0028.mp3
Normal file
BIN
mp3/0028.mp3
Normal file
Binary file not shown.
BIN
mp3/0029.mp3
Normal file
BIN
mp3/0029.mp3
Normal file
Binary file not shown.
BIN
mp3/0030.mp3
Normal file
BIN
mp3/0030.mp3
Normal file
Binary file not shown.
BIN
mp3/0031.mp3
Normal file
BIN
mp3/0031.mp3
Normal file
Binary file not shown.
BIN
mp3/0032.mp3
Normal file
BIN
mp3/0032.mp3
Normal file
Binary file not shown.
BIN
mp3/0033.mp3
Normal file
BIN
mp3/0033.mp3
Normal file
Binary file not shown.
BIN
mp3/0034.mp3
Normal file
BIN
mp3/0034.mp3
Normal file
Binary file not shown.
BIN
mp3/0035.mp3
Normal file
BIN
mp3/0035.mp3
Normal file
Binary file not shown.
BIN
mp3/0036.mp3
Normal file
BIN
mp3/0036.mp3
Normal file
Binary file not shown.
BIN
mp3/0037.mp3
Normal file
BIN
mp3/0037.mp3
Normal file
Binary file not shown.
BIN
mp3/0038.mp3
Normal file
BIN
mp3/0038.mp3
Normal file
Binary file not shown.
BIN
mp3/0039.mp3
Normal file
BIN
mp3/0039.mp3
Normal file
Binary file not shown.
BIN
mp3/0040.mp3
Normal file
BIN
mp3/0040.mp3
Normal file
Binary file not shown.
BIN
mp3/0041.mp3
Normal file
BIN
mp3/0041.mp3
Normal file
Binary file not shown.
BIN
mp3/0042.mp3
Normal file
BIN
mp3/0042.mp3
Normal file
Binary file not shown.
BIN
mp3/0043.mp3
Normal file
BIN
mp3/0043.mp3
Normal file
Binary file not shown.
BIN
mp3/0044.mp3
Normal file
BIN
mp3/0044.mp3
Normal file
Binary file not shown.
BIN
mp3/0045.mp3
Normal file
BIN
mp3/0045.mp3
Normal file
Binary file not shown.
BIN
mp3/0046.mp3
Normal file
BIN
mp3/0046.mp3
Normal file
Binary file not shown.
BIN
mp3/0047.mp3
Normal file
BIN
mp3/0047.mp3
Normal file
Binary file not shown.
BIN
mp3/0048.mp3
Normal file
BIN
mp3/0048.mp3
Normal file
Binary file not shown.
BIN
mp3/0049.mp3
Normal file
BIN
mp3/0049.mp3
Normal file
Binary file not shown.
BIN
mp3/0050.mp3
Normal file
BIN
mp3/0050.mp3
Normal file
Binary file not shown.
BIN
mp3/0051.mp3
Normal file
BIN
mp3/0051.mp3
Normal file
Binary file not shown.
BIN
mp3/0052.mp3
Normal file
BIN
mp3/0052.mp3
Normal file
Binary file not shown.
BIN
mp3/0053.mp3
Normal file
BIN
mp3/0053.mp3
Normal file
Binary file not shown.
BIN
mp3/0054.mp3
Normal file
BIN
mp3/0054.mp3
Normal file
Binary file not shown.
BIN
mp3/0055.mp3
Normal file
BIN
mp3/0055.mp3
Normal file
Binary file not shown.
BIN
mp3/0056.mp3
Normal file
BIN
mp3/0056.mp3
Normal file
Binary file not shown.
BIN
mp3/0057.mp3
Normal file
BIN
mp3/0057.mp3
Normal file
Binary file not shown.
BIN
mp3/0058.mp3
Normal file
BIN
mp3/0058.mp3
Normal file
Binary file not shown.
BIN
mp3/0059.mp3
Normal file
BIN
mp3/0059.mp3
Normal file
Binary file not shown.
BIN
mp3/0060.mp3
Normal file
BIN
mp3/0060.mp3
Normal file
Binary file not shown.
BIN
mp3/0061.mp3
Normal file
BIN
mp3/0061.mp3
Normal file
Binary file not shown.
BIN
mp3/0062.mp3
Normal file
BIN
mp3/0062.mp3
Normal file
Binary file not shown.
BIN
mp3/0063.mp3
Normal file
BIN
mp3/0063.mp3
Normal file
Binary file not shown.
BIN
mp3/0064.mp3
Normal file
BIN
mp3/0064.mp3
Normal file
Binary file not shown.
BIN
mp3/0065.mp3
Normal file
BIN
mp3/0065.mp3
Normal file
Binary file not shown.
BIN
mp3/0066.mp3
Normal file
BIN
mp3/0066.mp3
Normal file
Binary file not shown.
BIN
mp3/0067.mp3
Normal file
BIN
mp3/0067.mp3
Normal file
Binary file not shown.
BIN
mp3/0068.mp3
Normal file
BIN
mp3/0068.mp3
Normal file
Binary file not shown.
BIN
mp3/0069.mp3
Normal file
BIN
mp3/0069.mp3
Normal file
Binary file not shown.
BIN
mp3/0070.mp3
Normal file
BIN
mp3/0070.mp3
Normal file
Binary file not shown.
BIN
mp3/0071.mp3
Normal file
BIN
mp3/0071.mp3
Normal file
Binary file not shown.
BIN
mp3/0072.mp3
Normal file
BIN
mp3/0072.mp3
Normal file
Binary file not shown.
BIN
mp3/0073.mp3
Normal file
BIN
mp3/0073.mp3
Normal file
Binary file not shown.
BIN
mp3/0074.mp3
Normal file
BIN
mp3/0074.mp3
Normal file
Binary file not shown.
BIN
mp3/0075.mp3
Normal file
BIN
mp3/0075.mp3
Normal file
Binary file not shown.
BIN
mp3/0076.mp3
Normal file
BIN
mp3/0076.mp3
Normal file
Binary file not shown.
BIN
mp3/0077.mp3
Normal file
BIN
mp3/0077.mp3
Normal file
Binary file not shown.
BIN
mp3/0078.mp3
Normal file
BIN
mp3/0078.mp3
Normal file
Binary file not shown.
BIN
mp3/0079.mp3
Normal file
BIN
mp3/0079.mp3
Normal file
Binary file not shown.
BIN
mp3/0080.mp3
Normal file
BIN
mp3/0080.mp3
Normal file
Binary file not shown.
BIN
mp3/0081.mp3
Normal file
BIN
mp3/0081.mp3
Normal file
Binary file not shown.
BIN
mp3/0082.mp3
Normal file
BIN
mp3/0082.mp3
Normal file
Binary file not shown.
BIN
mp3/0083.mp3
Normal file
BIN
mp3/0083.mp3
Normal file
Binary file not shown.
BIN
mp3/0084.mp3
Normal file
BIN
mp3/0084.mp3
Normal file
Binary file not shown.
BIN
mp3/0085.mp3
Normal file
BIN
mp3/0085.mp3
Normal file
Binary file not shown.
BIN
mp3/0086.mp3
Normal file
BIN
mp3/0086.mp3
Normal file
Binary file not shown.
BIN
mp3/0087.mp3
Normal file
BIN
mp3/0087.mp3
Normal file
Binary file not shown.
BIN
mp3/0088.mp3
Normal file
BIN
mp3/0088.mp3
Normal file
Binary file not shown.
BIN
mp3/0089.mp3
Normal file
BIN
mp3/0089.mp3
Normal file
Binary file not shown.
BIN
mp3/0090.mp3
Normal file
BIN
mp3/0090.mp3
Normal file
Binary file not shown.
BIN
mp3/0091.mp3
Normal file
BIN
mp3/0091.mp3
Normal file
Binary file not shown.
BIN
mp3/0092.mp3
Normal file
BIN
mp3/0092.mp3
Normal file
Binary file not shown.
BIN
mp3/0093.mp3
Normal file
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
Reference in New Issue
Block a user