summaryrefslogtreecommitdiff
path: root/src/tangara/audio/audio_fsm.cpp
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-06-06 04:52:00 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-06-06 04:52:00 +0000
commit8de07fe8fac23d508ae64dfd6ffb332f568f4e45 (patch)
tree3e48ac0c3d9da1666f415040f378af2d42f62324 /src/tangara/audio/audio_fsm.cpp
parent1242a199e3e28deab4720c33d988b371bd11ed25 (diff)
downloadtangara-fw-8de07fe8fac23d508ae64dfd6ffb332f568f4e45.tar.gz
daniel/bluetooth-avrc (#80)
Have a squizzy and lemme know if any issues @cooljqln 🐝 Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/80 Co-authored-by: ailurux <ailuruxx@gmail.com> Co-committed-by: ailurux <ailuruxx@gmail.com>
Diffstat (limited to 'src/tangara/audio/audio_fsm.cpp')
-rw-r--r--src/tangara/audio/audio_fsm.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/tangara/audio/audio_fsm.cpp b/src/tangara/audio/audio_fsm.cpp
index d6ddff8d..80611082 100644
--- a/src/tangara/audio/audio_fsm.cpp
+++ b/src/tangara/audio/audio_fsm.cpp
@@ -217,18 +217,32 @@ void AudioState::react(const internal::StreamEnded& ev) {
}
void AudioState::react(const system_fsm::BluetoothEvent& ev) {
- if (ev.event != drivers::bluetooth::Event::kConnectionStateChanged) {
- return;
+ using drivers::bluetooth::SimpleEvent;
+ if (std::holds_alternative<SimpleEvent>(ev.event)) {
+ auto simpleEvent = std::get<SimpleEvent>(ev.event);
+ switch (simpleEvent) {
+ case SimpleEvent::kConnectionStateChanged: {
+ auto dev = sServices->bluetooth().ConnectedDevice();
+ if (!dev) {
+ return;
+ }
+ sBtOutput->SetVolume(sServices->nvs().BluetoothVolume(dev->mac));
+ events::Ui().Dispatch(VolumeChanged{
+ .percent = sOutput->GetVolumePct(),
+ .db = sOutput->GetVolumeDb(),
+ });
+ break;
+ }
+ default:
+ break;
+ }
}
- auto dev = sServices->bluetooth().ConnectedDevice();
- if (!dev) {
- return;
+ if (std::holds_alternative<drivers::bluetooth::RemoteVolumeChanged>(ev.event)) {
+ auto volume_chg = std::get<drivers::bluetooth::RemoteVolumeChanged>(ev.event).new_vol;
+ events::Ui().Dispatch(RemoteVolumeChanged{
+ .value = volume_chg
+ });
}
- sBtOutput->SetVolume(sServices->nvs().BluetoothVolume(dev->mac));
- events::Ui().Dispatch(VolumeChanged{
- .percent = sOutput->GetVolumePct(),
- .db = sOutput->GetVolumeDb(),
- });
}
void AudioState::react(const StepUpVolume& ev) {