From 5c04e2ad8d14616ce3ca09b658d25bab3d8d2460 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 4 Oct 2023 10:18:31 +1100 Subject: Neaten up the various kinds of inputs, and move volumes to The New Way --- src/audio/audio_fsm.cpp | 10 ++++------ src/audio/include/audio_events.hpp | 2 ++ src/audio/include/audio_fsm.hpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/audio') diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp index 6ea4f60d..e470300f 100644 --- a/src/audio/audio_fsm.cpp +++ b/src/audio/audio_fsm.cpp @@ -50,16 +50,14 @@ std::shared_ptr AudioState::sOutput; std::optional AudioState::sCurrentTrack; -void AudioState::react(const system_fsm::KeyUpChanged& ev) { - if (ev.falling && sOutput->AdjustVolumeUp()) { - ESP_LOGI(kTag, "volume up!"); +void AudioState::react(const StepUpVolume& ev) { + if (sOutput->AdjustVolumeUp()) { events::Ui().Dispatch(VolumeChanged{}); } } -void AudioState::react(const system_fsm::KeyDownChanged& ev) { - if (ev.falling && sOutput->AdjustVolumeDown()) { - ESP_LOGI(kTag, "volume down!"); +void AudioState::react(const StepDownVolume& ev) { + if (sOutput->AdjustVolumeDown()) { events::Ui().Dispatch(VolumeChanged{}); } } diff --git a/src/audio/include/audio_events.hpp b/src/audio/include/audio_events.hpp index 6b986462..b130938c 100644 --- a/src/audio/include/audio_events.hpp +++ b/src/audio/include/audio_events.hpp @@ -34,6 +34,8 @@ struct PlayFile : tinyfsm::Event { std::pmr::string filename; }; +struct StepUpVolume : tinyfsm::Event {}; +struct StepDownVolume : tinyfsm::Event {}; struct VolumeChanged : tinyfsm::Event {}; struct ChangeMaxVolume : tinyfsm::Event { uint16_t new_max; diff --git a/src/audio/include/audio_fsm.hpp b/src/audio/include/audio_fsm.hpp index 1c0b8aaa..256e1430 100644 --- a/src/audio/include/audio_fsm.hpp +++ b/src/audio/include/audio_fsm.hpp @@ -41,8 +41,8 @@ class AudioState : public tinyfsm::Fsm { /* Fallback event handler. Does nothing. */ void react(const tinyfsm::Event& ev) {} - void react(const system_fsm::KeyUpChanged&); - void react(const system_fsm::KeyDownChanged&); + void react(const StepUpVolume&); + void react(const StepDownVolume&); void react(const system_fsm::HasPhonesChanged&); void react(const ChangeMaxVolume&); void react(const OutputModeChanged&); -- cgit v1.2.3