4
0
Fork 0
mirror of https://github.com/zzzzDev4/IAS-Better-Tea.git synced 2025-04-21 07:31:20 +02:00

added sounds

This commit is contained in:
zzzz 2024-06-26 23:29:43 +02:00
parent 25765a179f
commit 9629becc54
2 changed files with 89 additions and 1 deletions

View file

@ -39,6 +39,82 @@ void SmartSound::playStartSteepingSound()
noTone(m_buzzerPin);
}
void SmartSound::playTurnOnSound() {
tone(m_buzzerPin, NOTE_C4, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_D4, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_A3, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_D4, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_D5, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_C5, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_C6, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_C5, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
}
void SmartSound::playSaveSound() {
tone(m_buzzerPin, NOTE_D4, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_A4, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_D5, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
}
void SmartSound::playSuccessSound() {
tone(m_buzzerPin, NOTE_D5, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_A5, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
}
void SmartSound::playFailureSound() {
tone(m_buzzerPin, NOTE_D5, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
tone(m_buzzerPin, NOTE_GS3, 150 * 0.9);
delay(150);
noTone(m_buzzerPin);
}
void SmartSound::playTeaReadySound() {
playStartSteepingSound();
delay(200);
playStartSteepingSound();
delay(200);
playStartSteepingSound();
}
void SmartSound::play(Sound sound, int tempo)
{
switch (sound)

View file

@ -52,6 +52,7 @@ unsigned long timeoutTimeMillis;
#define CATCH_NET_FAILURE(netResult, msg) \
if (netResult == JSON.parse("{}")) \
{ \
sound.playFailureSound(); \
smartDisplay.printMsg(msg); \
delay(500); \
break; \
@ -79,6 +80,8 @@ void setup()
{
Serial.begin(9600);
sound.playTurnOnSound();
smartServo.moveServoToZero();
smartStrip.init();
@ -96,7 +99,6 @@ void setup()
teaNet.init(ssid, password);
// load config
JSONVar result = teaNet.httpsGETRequest(shuttleServer + "/configuration");
// catch possible failure
@ -179,6 +181,7 @@ void loop()
}
case PROCESS_RFID_SCAN:
{
sound.playSuccessSound();
smartDisplay.playTeaAnimationPartOne(32, "", "Loading...", "", "");
Serial.println(currentTea.m_rfidCode);
@ -269,6 +272,7 @@ void loop()
// abort if red button pressed
if (buttonLeft.isDown() && buttonRight.isDown())
{
sound.playFailureSound();
teaTimer.endSteeping();
smartDisplay.printMsg("Aborting...");
smartStrip.animateBottomToTop(1, 0, 0);
@ -287,6 +291,7 @@ void loop()
else
{
smartDisplay.printMsg("Ready!");
sound.playTeaReadySound();
smartStrip.animateBottomToTop(0, 1, 0);
state = State::REQUEST_FEEDBACK;
timeoutTimeMillis = millis() + (feedbackTimeoutSeconds * 1000);
@ -341,6 +346,7 @@ void loop()
if (isTouchBtnPressed())
{
sound.playSuccessSound();
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(perfect)", "", "saving...");
// keep steeping time for next brew
@ -359,6 +365,7 @@ void loop()
}
if (buttonLeft.isJustPressed())
{
sound.playSuccessSound();
// decrease steeping time for next brew
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(shorter)", "", "saving...");
@ -385,6 +392,7 @@ void loop()
}
if (buttonRight.isJustPressed())
{
sound.playSuccessSound();
// increase steeping time for next brew
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(longer)", "", "saving...");
@ -431,10 +439,13 @@ void loop()
{
currentTea.m_steepingSeconds = 0;
}
else
sound.playMinusSound();
}
if (buttonRight.isJustPressed())
{
currentTea.m_steepingSeconds += 10;
sound.playPlusSound();
}
if (isTouchBtnPressed())
@ -446,6 +457,7 @@ void loop()
CATCH_NET_FAILURE(result, "POST FAILED")
sound.playSaveSound();
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
state = State::DISPLAY_SCANNED_TEA_CONFIG;
}