mirror of
https://github.com/xfjx/TonUINO.git
synced 2025-08-22 13:53:02 +02:00
Added Support for 5 Buttons // Unterstützung von 5 Knöpfen hinzugefügt
This commit is contained in:
89
Tonuino.ino
89
Tonuino.ino
@@ -6,6 +6,20 @@
|
|||||||
#include <SoftwareSerial.h>
|
#include <SoftwareSerial.h>
|
||||||
#include <avr/sleep.h>
|
#include <avr/sleep.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
_____ _____ _____ _____ _____
|
||||||
|
|_ _|___ ___| | | | | | |
|
||||||
|
| | | . | | | |- -| | | | | |
|
||||||
|
|_| |___|_|_|_____|_____|_|___|_____|
|
||||||
|
TonUINO Version 2.1
|
||||||
|
|
||||||
|
created by Thorsten Voß and licensed under GNU/GPL.
|
||||||
|
Information and contribution at https://tonuino.de.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// uncomment the below line to enable five button support
|
||||||
|
//#define FIVEBUTTONS
|
||||||
|
|
||||||
static const uint32_t cardCookie = 322417479;
|
static const uint32_t cardCookie = 322417479;
|
||||||
|
|
||||||
// DFPlayer Mini
|
// DFPlayer Mini
|
||||||
@@ -300,15 +314,27 @@ MFRC522::StatusCode status;
|
|||||||
#define busyPin 4
|
#define busyPin 4
|
||||||
#define shutdownPin 7
|
#define shutdownPin 7
|
||||||
|
|
||||||
|
#ifdef FIVEBUTTONS
|
||||||
|
#define buttonFourPin A3
|
||||||
|
#define buttonFivePin A4
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LONG_PRESS 1000
|
#define LONG_PRESS 1000
|
||||||
|
|
||||||
Button pauseButton(buttonPause);
|
Button pauseButton(buttonPause);
|
||||||
Button upButton(buttonUp);
|
Button upButton(buttonUp);
|
||||||
Button downButton(buttonDown);
|
Button downButton(buttonDown);
|
||||||
|
#ifdef FIVEBUTTONS
|
||||||
|
Button buttonFour(buttonFourPin);
|
||||||
|
Button buttonFive(buttonFivePin);
|
||||||
|
#endif
|
||||||
bool ignorePauseButton = false;
|
bool ignorePauseButton = false;
|
||||||
bool ignoreUpButton = false;
|
bool ignoreUpButton = false;
|
||||||
bool ignoreDownButton = false;
|
bool ignoreDownButton = false;
|
||||||
|
#ifdef FIVEBUTTONS
|
||||||
|
bool ignoreButtonFour = false;
|
||||||
|
bool ignoreButtonFive = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Funktionen für den Standby Timer (z.B. über Pololu-Switch oder Mosfet)
|
/// Funktionen für den Standby Timer (z.B. über Pololu-Switch oder Mosfet)
|
||||||
|
|
||||||
@@ -407,10 +433,14 @@ void setup() {
|
|||||||
pinMode(buttonPause, INPUT_PULLUP);
|
pinMode(buttonPause, INPUT_PULLUP);
|
||||||
pinMode(buttonUp, INPUT_PULLUP);
|
pinMode(buttonUp, INPUT_PULLUP);
|
||||||
pinMode(buttonDown, INPUT_PULLUP);
|
pinMode(buttonDown, INPUT_PULLUP);
|
||||||
|
#ifdef FIVEBUTTONS
|
||||||
|
pinMode(buttonFourPin, INPUT_PULLUP);
|
||||||
|
pinMode(buttonFivePin, INPUT_PULLUP);
|
||||||
|
#endif
|
||||||
pinMode(shutdownPin, OUTPUT);
|
pinMode(shutdownPin, OUTPUT);
|
||||||
digitalWrite(shutdownPin, LOW);
|
digitalWrite(shutdownPin, LOW);
|
||||||
|
|
||||||
// RESET --- ALLE DREI KNÖPFE BEIM STARTEN GEDRÜCKT HALTEN -> alle EINSTELLUNGEN werden gelöscht
|
/* // RESET --- ALLE DREI KNÖPFE BEIM STARTEN GEDRÜCKT HALTEN -> alle EINSTELLUNGEN werden gelöscht
|
||||||
if (digitalRead(buttonPause) == LOW && digitalRead(buttonUp) == LOW &&
|
if (digitalRead(buttonPause) == LOW && digitalRead(buttonUp) == LOW &&
|
||||||
digitalRead(buttonDown) == LOW) {
|
digitalRead(buttonDown) == LOW) {
|
||||||
Serial.println(F("Reset -> EEPROM wird gelöscht"));
|
Serial.println(F("Reset -> EEPROM wird gelöscht"));
|
||||||
@@ -418,6 +448,7 @@ void setup() {
|
|||||||
EEPROM.update(i, 0);
|
EEPROM.update(i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Start Shortcut "at Startup" - e.g. Welcome Sound
|
// Start Shortcut "at Startup" - e.g. Welcome Sound
|
||||||
playShortCut(3);
|
playShortCut(3);
|
||||||
}
|
}
|
||||||
@@ -426,6 +457,10 @@ void readButtons() {
|
|||||||
pauseButton.read();
|
pauseButton.read();
|
||||||
upButton.read();
|
upButton.read();
|
||||||
downButton.read();
|
downButton.read();
|
||||||
|
#ifdef FIVEBUTTONS
|
||||||
|
buttonFour.read();
|
||||||
|
buttonFive.read();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void volumeUpButton() {
|
void volumeUpButton() {
|
||||||
@@ -606,6 +641,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (upButton.pressedFor(LONG_PRESS)) {
|
if (upButton.pressedFor(LONG_PRESS)) {
|
||||||
|
#ifndef FIVEBUTTONS
|
||||||
if (isPlaying()) {
|
if (isPlaying()) {
|
||||||
if (!mySettings.invertVolumeButtons) {
|
if (!mySettings.invertVolumeButtons) {
|
||||||
volumeUpButton();
|
volumeUpButton();
|
||||||
@@ -618,6 +654,7 @@ void loop() {
|
|||||||
playShortCut(1);
|
playShortCut(1);
|
||||||
}
|
}
|
||||||
ignoreUpButton = true;
|
ignoreUpButton = true;
|
||||||
|
#endif
|
||||||
} else if (upButton.wasReleased()) {
|
} else if (upButton.wasReleased()) {
|
||||||
if (!ignoreUpButton)
|
if (!ignoreUpButton)
|
||||||
if (!mySettings.invertVolumeButtons) {
|
if (!mySettings.invertVolumeButtons) {
|
||||||
@@ -630,6 +667,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (downButton.pressedFor(LONG_PRESS)) {
|
if (downButton.pressedFor(LONG_PRESS)) {
|
||||||
|
#ifndef FIVEBUTTONS
|
||||||
if (isPlaying()) {
|
if (isPlaying()) {
|
||||||
if (!mySettings.invertVolumeButtons) {
|
if (!mySettings.invertVolumeButtons) {
|
||||||
volumeDownButton();
|
volumeDownButton();
|
||||||
@@ -642,6 +680,7 @@ void loop() {
|
|||||||
playShortCut(2);
|
playShortCut(2);
|
||||||
}
|
}
|
||||||
ignoreDownButton = true;
|
ignoreDownButton = true;
|
||||||
|
#endif
|
||||||
} else if (downButton.wasReleased()) {
|
} else if (downButton.wasReleased()) {
|
||||||
if (!ignoreDownButton) {
|
if (!ignoreDownButton) {
|
||||||
if (!mySettings.invertVolumeButtons) {
|
if (!mySettings.invertVolumeButtons) {
|
||||||
@@ -653,6 +692,34 @@ void loop() {
|
|||||||
}
|
}
|
||||||
ignoreDownButton = false;
|
ignoreDownButton = false;
|
||||||
}
|
}
|
||||||
|
#ifdef FIVEBUTTONS
|
||||||
|
if (buttonFour.wasReleased()) {
|
||||||
|
if (isPlaying()) {
|
||||||
|
if (!mySettings.invertVolumeButtons) {
|
||||||
|
volumeUpButton();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nextButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playShortCut(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buttonFive.wasReleased()) {
|
||||||
|
if (isPlaying()) {
|
||||||
|
if (!mySettings.invertVolumeButtons) {
|
||||||
|
volumeDownButton();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
previousButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playShortCut(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// Ende der Buttons
|
// Ende der Buttons
|
||||||
} while (!mfrc522.PICC_IsNewCardPresent());
|
} while (!mfrc522.PICC_IsNewCardPresent());
|
||||||
|
|
||||||
@@ -780,6 +847,22 @@ void adminMenu() {
|
|||||||
setstandbyTimer();
|
setstandbyTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool askCode(uint8_t *code) {
|
||||||
|
uint8_t x = 0;
|
||||||
|
while (x < 3) {
|
||||||
|
readButtons();
|
||||||
|
if (pauseButton.pressedFor(LONG_PRESS))
|
||||||
|
break;
|
||||||
|
if (pauseButton.wasReleased())
|
||||||
|
code[x++] = 1;
|
||||||
|
if (upButton.wasReleased())
|
||||||
|
code[x++] = 2;
|
||||||
|
if (downButton.wasReleased())
|
||||||
|
code[x++] = 3;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
|
uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
|
||||||
bool preview = false, int previewFromFolder = 0, int defaultValue = 0, bool exitWithLongPress = false) {
|
bool preview = false, int previewFromFolder = 0, int defaultValue = 0, bool exitWithLongPress = false) {
|
||||||
uint8_t returnValue = defaultValue;
|
uint8_t returnValue = defaultValue;
|
||||||
@@ -897,7 +980,7 @@ void resetCard() {
|
|||||||
if (!mfrc522.PICC_ReadCardSerial())
|
if (!mfrc522.PICC_ReadCardSerial())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Serial.print(F("Karte wird neu Konfiguriert!"));
|
Serial.print(F("Karte wird neu konfiguriert!"));
|
||||||
setupCard();
|
setupCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user