Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement VolumeLimiter #71

Open
wants to merge 1 commit into
base: DEV
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Tonuino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,29 @@ class RepeatSingleModifier: public Modifier {
}
};

class VolumeLimiter: public Modifier {
private:
uint8_t maxVolume;

public:
VolumeLimiter(uint8_t maxVolume) {
Serial.println("Volume limiter active");
Serial.print("Max Volume: ");
Serial.println(maxVolume);
this->maxVolume = maxVolume;
volume = mySettings.minVolume;
delay(500);
mp3.setVolume(volume);
}

virtual bool handleVolumeUp() {
return (volume >= maxVolume);
}
virtual uint8_t getActive() {
return 7;
}
};

// An modifier can also do somethings in addition to the modified action
// by returning false (not handled) at the end
// This simple FeedbackModifier will tell the volume before changing it and
Expand Down Expand Up @@ -1671,6 +1694,7 @@ bool readCard(nfcTagObject * nfcTag) {
case 4: activeModifier = new ToddlerMode(); break;
case 5: activeModifier = new KindergardenMode(); break;
case 6: activeModifier = new RepeatSingleModifier(); break;
case 7: activeModifier = new VolumeLimiter(tempCard.nfcFolderSettings.special); break;

}
delay(2000);
Expand Down