Skip to content

Commit

Permalink
Merge pull request #208: Issue_207: Use poti for setting the volume: …
Browse files Browse the repository at this point in the history
…add threshold to prevent
  • Loading branch information
boerge1 authored Jun 5, 2024
2 parents 715a6e4 + 58f181a commit e3cfaae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.8 geän
# Change Log

## Version 3.1.9 (05.06.2024)
- [Issue 207](https://github.com/tonuino/TonUINO-TNG/issues/207): Use poti for setting the volume: add threshold to prevent continuously switching volume
- [Issue 205](https://github.com/tonuino/TonUINO-TNG/issues/205): Implement the game "Feuer, Wasser, Luft" as modification card

## Version 3.1.8 (26.04.2024)
Expand Down
11 changes: 7 additions & 4 deletions src/poti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@
#endif


Poti::Poti(const Settings& settings, Mp3& mp3)
Poti::Poti(Mp3& mp3)
: CommandSource()
, settings(settings)
, mp3(mp3)
{
pinMode(potiPin, INPUT);
}

commandRaw Poti::getCommandRaw() {
const uint8_t volume = map( analogRead(potiPin), 0, maxLevel, settings.minVolume, settings.maxVolume);
const uint8_t volume = map( analogRead(potiPin), 0, maxLevel, mp3.getMinVolume(), mp3.getMaxVolume());

if (volume != mp3.getVolume()) {
if (volume < mp3.getVolume()) {
LOG(button_log, s_debug, F("poti volume: "), volume);
mp3.setVolume(volume);
}
else if (volume > mp3.getVolume()+1) {
LOG(button_log, s_debug, F("poti volume: "), volume-1);
mp3.setVolume(volume-1);
}

return commandRaw::none;
}
Expand Down
3 changes: 1 addition & 2 deletions src/poti.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ class Mp3;
class Poti: public CommandSource {
public:

Poti(const Settings& settings, Mp3& mp3);
Poti(Mp3& mp3);
commandRaw getCommandRaw() override;

private:
const Settings& settings;
Mp3& mp3;
};

Expand Down
2 changes: 1 addition & 1 deletion src/tonuino.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Tonuino {
RotaryEncoder rotaryEncoder {settings};
#endif
#ifdef POTI
Poti poti {settings, mp3};
Poti poti {mp3};
#endif
Commands commands {
settings
Expand Down

0 comments on commit e3cfaae

Please sign in to comment.