diff --git a/src/SmartButton.cpp b/src/SmartButton.cpp index e98dd9f..610617f 100644 --- a/src/SmartButton.cpp +++ b/src/SmartButton.cpp @@ -24,4 +24,9 @@ bool SmartButton::isJustPressed() return true; } return false; +} + +bool SmartButton::isDown() +{ + return digitalRead(m_pin) == LOW; } \ No newline at end of file diff --git a/src/SmartButton.hpp b/src/SmartButton.hpp index 4691ab7..ae613e5 100644 --- a/src/SmartButton.hpp +++ b/src/SmartButton.hpp @@ -5,6 +5,7 @@ class SmartButton { SmartButton(int pin); void init(); bool isJustPressed(); + bool isDown(); private: bool m_isDown; int m_pin; diff --git a/src/SmartDisplay.cpp b/src/SmartDisplay.cpp index 6601110..171ef36 100644 --- a/src/SmartDisplay.cpp +++ b/src/SmartDisplay.cpp @@ -112,6 +112,19 @@ void SmartDisplay::printTeaConfigScreen(TeaData tea) m_display->display(); } +void SmartDisplay::displayTeaNotes(TeaData tea) { + resetDisplay(); + + m_display->println(tea.m_teaName); + + m_display->writeFastHLine(0, m_display->getCursorY(), 128, WHITE); + + m_display->setCursor(m_display->getCursorX(), m_display->getCursorY() + 3); + m_display->print(tea.m_teaNotes); + + m_display->display(); +} + void SmartDisplay::printTeaSteepingProgressScreen(TeaData tea, int remainingSeconds) { resetDisplay(); diff --git a/src/SmartDisplay.hpp b/src/SmartDisplay.hpp index 55430db..a1779ce 100644 --- a/src/SmartDisplay.hpp +++ b/src/SmartDisplay.hpp @@ -18,6 +18,7 @@ public: public: // special screens void printAddNewTeaConfigScreen(TeaData tea, u_int *flicker); + void displayTeaNotes(TeaData tea); // animations void playTeaAnimation(); diff --git a/src/SmartSound.cpp b/src/SmartSound.cpp index 1701d02..960f844 100644 --- a/src/SmartSound.cpp +++ b/src/SmartSound.cpp @@ -6,6 +6,39 @@ SmartSound::SmartSound(int buzzerPin) m_buzzerPin = buzzerPin; } +void SmartSound::playPlusSound() +{ + tone(m_buzzerPin, NOTE_GS4, 50 * 0.9); + delay(50); + noTone(m_buzzerPin); +} + +void SmartSound::playMinusSound() +{ + tone(m_buzzerPin, NOTE_G4, 50 * 0.9); + delay(50); + noTone(m_buzzerPin); +} + +void SmartSound::playStartSteepingSound() +{ + tone(m_buzzerPin, NOTE_C4, 150 * 0.9); + delay(150); + noTone(m_buzzerPin); + + tone(m_buzzerPin, NOTE_E4, 150 * 0.9); + delay(150); + noTone(m_buzzerPin); + + tone(m_buzzerPin, NOTE_G4, 150 * 0.9); + delay(150); + noTone(m_buzzerPin); + + tone(m_buzzerPin, NOTE_C5, 150 * 0.9); + delay(150); + noTone(m_buzzerPin); +} + void SmartSound::play(Sound sound, int tempo) { switch (sound) diff --git a/src/SmartSound.hpp b/src/SmartSound.hpp index 614df2b..5bc02da 100644 --- a/src/SmartSound.hpp +++ b/src/SmartSound.hpp @@ -14,6 +14,17 @@ public: SmartSound(int buzzerPin); void play(Sound sound, int tempo = 144); + // interaction sounds + void playSuccessSound(); + void playFailureSound(); + void playTeaReadySound(); + void playStartSteepingSound(); + void playTurnOnSound(); + void playSaveSound(); + void playPlusSound(); + void playMinusSound(); + + private: int m_buzzerPin; void playSound(int melody[], int notes, int tempo = 114); diff --git a/src/main.cpp b/src/main.cpp index b97a3e6..427c2b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -220,12 +220,26 @@ void loop() { currentTea.m_steepingSeconds = 0; } + else + { + sound.playMinusSound(); + } } if (buttonRight.isJustPressed()) { currentTea.m_steepingSeconds += 10; + sound.playPlusSound(); + } + + if (buttonLeft.isDown() && buttonRight.isDown()) + { + smartDisplay.displayTeaNotes(currentTea); + break; + } + else + { + smartDisplay.printTeaConfigScreen(currentTea); } - smartDisplay.printTeaConfigScreen(currentTea); if (isTouchBtnPressed() && currentTea.m_steepingSeconds <= 0) { @@ -238,6 +252,7 @@ void loop() // change state if start pressed if (isTouchBtnPressed()) { + sound.playStartSteepingSound(); teaTimer.beginSteeping(currentTea.m_steepingSeconds * 1000); state = State::STEEPING_IN_PROGRESS; smartStrip.reset(); @@ -250,7 +265,7 @@ void loop() if (teaTimer.isSteeping()) { // abort if red button pressed - if (buttonLeft.isJustPressed() && buttonRight.isJustPressed()) + if (buttonLeft.isDown() && buttonRight.isDown()) { teaTimer.endSteeping(); smartDisplay.printMsg("Aborting...");