summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-10-04 10:18:31 +1100
committerjacqueline <me@jacqueline.id.au>2023-10-04 10:18:31 +1100
commit5c04e2ad8d14616ce3ca09b658d25bab3d8d2460 (patch)
tree411b269ca33ddadb0a95ac74a171b53a5fc7ac07 /src/audio
parentc851b789faf71d0ef2092ae7d8cd3190c13d85c9 (diff)
downloadtangara-fw-5c04e2ad8d14616ce3ca09b658d25bab3d8d2460.tar.gz
Neaten up the various kinds of inputs, and move volumes to The New Way
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/audio_fsm.cpp10
-rw-r--r--src/audio/include/audio_events.hpp2
-rw-r--r--src/audio/include/audio_fsm.hpp4
3 files changed, 8 insertions, 8 deletions
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<IAudioOutput> AudioState::sOutput;
std::optional<database::TrackId> 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<AudioState> {
/* 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&);