mirror of
https://github.com/zzzzDev4/IAS-Better-Tea.git
synced 2025-04-21 07:31:20 +02:00
WIP sound design and small bugfixes
This commit is contained in:
parent
35d334dd29
commit
093f812dd5
7 changed files with 81 additions and 2 deletions
|
@ -24,4 +24,9 @@ bool SmartButton::isJustPressed()
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SmartButton::isDown()
|
||||
{
|
||||
return digitalRead(m_pin) == LOW;
|
||||
}
|
|
@ -5,6 +5,7 @@ class SmartButton {
|
|||
SmartButton(int pin);
|
||||
void init();
|
||||
bool isJustPressed();
|
||||
bool isDown();
|
||||
private:
|
||||
bool m_isDown;
|
||||
int m_pin;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
public:
|
||||
// special screens
|
||||
void printAddNewTeaConfigScreen(TeaData tea, u_int *flicker);
|
||||
void displayTeaNotes(TeaData tea);
|
||||
|
||||
// animations
|
||||
void playTeaAnimation();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
19
src/main.cpp
19
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...");
|
||||
|
|
Loading…
Add table
Reference in a new issue