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:
parent
25765a179f
commit
9629becc54
2 changed files with 89 additions and 1 deletions
|
@ -39,6 +39,82 @@ void SmartSound::playStartSteepingSound()
|
||||||
noTone(m_buzzerPin);
|
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)
|
void SmartSound::play(Sound sound, int tempo)
|
||||||
{
|
{
|
||||||
switch (sound)
|
switch (sound)
|
||||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -52,6 +52,7 @@ unsigned long timeoutTimeMillis;
|
||||||
#define CATCH_NET_FAILURE(netResult, msg) \
|
#define CATCH_NET_FAILURE(netResult, msg) \
|
||||||
if (netResult == JSON.parse("{}")) \
|
if (netResult == JSON.parse("{}")) \
|
||||||
{ \
|
{ \
|
||||||
|
sound.playFailureSound(); \
|
||||||
smartDisplay.printMsg(msg); \
|
smartDisplay.printMsg(msg); \
|
||||||
delay(500); \
|
delay(500); \
|
||||||
break; \
|
break; \
|
||||||
|
@ -79,6 +80,8 @@ void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
|
sound.playTurnOnSound();
|
||||||
|
|
||||||
smartServo.moveServoToZero();
|
smartServo.moveServoToZero();
|
||||||
|
|
||||||
smartStrip.init();
|
smartStrip.init();
|
||||||
|
@ -96,7 +99,6 @@ void setup()
|
||||||
|
|
||||||
teaNet.init(ssid, password);
|
teaNet.init(ssid, password);
|
||||||
|
|
||||||
|
|
||||||
// load config
|
// load config
|
||||||
JSONVar result = teaNet.httpsGETRequest(shuttleServer + "/configuration");
|
JSONVar result = teaNet.httpsGETRequest(shuttleServer + "/configuration");
|
||||||
// catch possible failure
|
// catch possible failure
|
||||||
|
@ -179,6 +181,7 @@ void loop()
|
||||||
}
|
}
|
||||||
case PROCESS_RFID_SCAN:
|
case PROCESS_RFID_SCAN:
|
||||||
{
|
{
|
||||||
|
sound.playSuccessSound();
|
||||||
smartDisplay.playTeaAnimationPartOne(32, "", "Loading...", "", "");
|
smartDisplay.playTeaAnimationPartOne(32, "", "Loading...", "", "");
|
||||||
|
|
||||||
Serial.println(currentTea.m_rfidCode);
|
Serial.println(currentTea.m_rfidCode);
|
||||||
|
@ -269,6 +272,7 @@ void loop()
|
||||||
// abort if red button pressed
|
// abort if red button pressed
|
||||||
if (buttonLeft.isDown() && buttonRight.isDown())
|
if (buttonLeft.isDown() && buttonRight.isDown())
|
||||||
{
|
{
|
||||||
|
sound.playFailureSound();
|
||||||
teaTimer.endSteeping();
|
teaTimer.endSteeping();
|
||||||
smartDisplay.printMsg("Aborting...");
|
smartDisplay.printMsg("Aborting...");
|
||||||
smartStrip.animateBottomToTop(1, 0, 0);
|
smartStrip.animateBottomToTop(1, 0, 0);
|
||||||
|
@ -287,6 +291,7 @@ void loop()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
smartDisplay.printMsg("Ready!");
|
smartDisplay.printMsg("Ready!");
|
||||||
|
sound.playTeaReadySound();
|
||||||
smartStrip.animateBottomToTop(0, 1, 0);
|
smartStrip.animateBottomToTop(0, 1, 0);
|
||||||
state = State::REQUEST_FEEDBACK;
|
state = State::REQUEST_FEEDBACK;
|
||||||
timeoutTimeMillis = millis() + (feedbackTimeoutSeconds * 1000);
|
timeoutTimeMillis = millis() + (feedbackTimeoutSeconds * 1000);
|
||||||
|
@ -341,6 +346,7 @@ void loop()
|
||||||
|
|
||||||
if (isTouchBtnPressed())
|
if (isTouchBtnPressed())
|
||||||
{
|
{
|
||||||
|
sound.playSuccessSound();
|
||||||
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(perfect)", "", "saving...");
|
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(perfect)", "", "saving...");
|
||||||
|
|
||||||
// keep steeping time for next brew
|
// keep steeping time for next brew
|
||||||
|
@ -359,6 +365,7 @@ void loop()
|
||||||
}
|
}
|
||||||
if (buttonLeft.isJustPressed())
|
if (buttonLeft.isJustPressed())
|
||||||
{
|
{
|
||||||
|
sound.playSuccessSound();
|
||||||
// decrease steeping time for next brew
|
// decrease steeping time for next brew
|
||||||
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(shorter)", "", "saving...");
|
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(shorter)", "", "saving...");
|
||||||
|
|
||||||
|
@ -385,6 +392,7 @@ void loop()
|
||||||
}
|
}
|
||||||
if (buttonRight.isJustPressed())
|
if (buttonRight.isJustPressed())
|
||||||
{
|
{
|
||||||
|
sound.playSuccessSound();
|
||||||
// increase steeping time for next brew
|
// increase steeping time for next brew
|
||||||
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(longer)", "", "saving...");
|
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(longer)", "", "saving...");
|
||||||
|
|
||||||
|
@ -431,10 +439,13 @@ void loop()
|
||||||
{
|
{
|
||||||
currentTea.m_steepingSeconds = 0;
|
currentTea.m_steepingSeconds = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
sound.playMinusSound();
|
||||||
}
|
}
|
||||||
if (buttonRight.isJustPressed())
|
if (buttonRight.isJustPressed())
|
||||||
{
|
{
|
||||||
currentTea.m_steepingSeconds += 10;
|
currentTea.m_steepingSeconds += 10;
|
||||||
|
sound.playPlusSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTouchBtnPressed())
|
if (isTouchBtnPressed())
|
||||||
|
@ -446,6 +457,7 @@ void loop()
|
||||||
|
|
||||||
CATCH_NET_FAILURE(result, "POST FAILED")
|
CATCH_NET_FAILURE(result, "POST FAILED")
|
||||||
|
|
||||||
|
sound.playSaveSound();
|
||||||
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
|
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
|
||||||
state = State::DISPLAY_SCANNED_TEA_CONFIG;
|
state = State::DISPLAY_SCANNED_TEA_CONFIG;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue