Lautstärke-Änderungen in 2er-Schritten.

This commit is contained in:
Fabian Schlenz 2022-08-21 17:42:58 +02:00
parent aed9c416bf
commit 9a39b00a65
1 changed files with 7 additions and 2 deletions

View File

@ -12,12 +12,17 @@ void Controller::handle() {
void Controller::handle_buttons() {
if (is_button_pressed(PIN_BTN_VOL_UP)) {
log_i("BTN_VOL_UP pressed");
uint8_t vol = min(audio.getVolume()+1, 21);
uint8_t vol = min(audio.getVolume()+2, 21);
log_d("Setting new volume %d", vol);
audio.setVolume(vol);
} else if (is_button_pressed(PIN_BTN_VOL_DOWN)) {
log_i("BTN_VOL_DOWN pressed");
uint8_t vol = max(audio.getVolume()-1, 1);
uint8_t vol;
if ((vol = audio.getVolume()) >= 3) {
vol -= 2;
} else {
vol = 1;
}
log_d("Setting new volume %d", vol);
audio.setVolume(vol);
} else if (is_button_pressed(PIN_BTN_TRACK_NEXT)) {