summaryrefslogtreecommitdiff
path: root/src/tangara/ui
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/ui
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/ui')
-rw-r--r--src/tangara/ui/ui_fsm.cpp70
-rw-r--r--src/tangara/ui/ui_fsm.hpp1
2 files changed, 52 insertions, 19 deletions
diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp
index 17d6c511..e367586b 100644
--- a/src/tangara/ui/ui_fsm.cpp
+++ b/src/tangara/ui/ui_fsm.cpp
@@ -387,6 +387,10 @@ void UiState::react(const audio::VolumeChanged& ev) {
sVolumeCurrentDb.setDirect(static_cast<int>(ev.db));
}
+void UiState::react(const audio::RemoteVolumeChanged& ev) {
+ // TODO: Show dialog
+}
+
void UiState::react(const audio::VolumeBalanceChanged& ev) {
sVolumeLeftBias.setDirect(ev.left_bias);
}
@@ -396,27 +400,55 @@ void UiState::react(const audio::VolumeLimitChanged& ev) {
}
void UiState::react(const system_fsm::BluetoothEvent& ev) {
+ using drivers::bluetooth::SimpleEvent;
auto bt = sServices->bluetooth();
auto dev = bt.ConnectedDevice();
- switch (ev.event) {
- case drivers::bluetooth::Event::kKnownDevicesChanged:
- sBluetoothDevices.setDirect(bt.KnownDevices());
- break;
- case drivers::bluetooth::Event::kConnectionStateChanged:
- sBluetoothConnected.setDirect(bt.IsConnected());
- if (dev) {
- sBluetoothPairedDevice.setDirect(drivers::bluetooth::Device{
- .address = dev->mac,
- .name = {dev->name.data(), dev->name.size()},
- .class_of_device = 0,
- .signal_strength = 0,
- });
- } else {
- sBluetoothPairedDevice.setDirect(std::monostate{});
- }
- break;
- case drivers::bluetooth::Event::kPreferredDeviceChanged:
- break;
+ if (std::holds_alternative<SimpleEvent>(ev.event)) {
+ switch (std::get<SimpleEvent>(ev.event)) {
+ case SimpleEvent::kPlayPause:
+ events::Audio().Dispatch(audio::TogglePlayPause{});
+ break;
+ case SimpleEvent::kStop:
+ events::Audio().Dispatch(audio::TogglePlayPause{.set_to = false});
+ break;
+ case SimpleEvent::kMute:
+ break;
+ case SimpleEvent::kVolUp:
+ break;
+ case SimpleEvent::kVolDown:
+ break;
+ case SimpleEvent::kForward:
+ break;
+ case SimpleEvent::kBackward:
+ break;
+ case SimpleEvent::kRewind:
+ break;
+ case SimpleEvent::kFastForward:
+ break;
+ case SimpleEvent::kKnownDevicesChanged:
+ sBluetoothDevices.setDirect(bt.KnownDevices());
+ break;
+ case SimpleEvent::kConnectionStateChanged:
+ sBluetoothConnected.setDirect(bt.IsConnected());
+ if (dev) {
+ sBluetoothPairedDevice.setDirect(drivers::bluetooth::Device{
+ .address = dev->mac,
+ .name = {dev->name.data(), dev->name.size()},
+ .class_of_device = 0,
+ .signal_strength = 0,
+ });
+ } else {
+ sBluetoothPairedDevice.setDirect(std::monostate{});
+ }
+ break;
+ case SimpleEvent::kPreferredDeviceChanged:
+ break;
+ default:
+ break;
+ }
+ } else if (std::holds_alternative<drivers::bluetooth::RemoteVolumeChanged>(ev.event)) {
+ // Todo: Do something with this (ie, bt volume alert)
+ ESP_LOGI(kTag, "Recieved volume changed event with new volume: %d", std::get<drivers::bluetooth::RemoteVolumeChanged>(ev.event).new_vol);
}
}
diff --git a/src/tangara/ui/ui_fsm.hpp b/src/tangara/ui/ui_fsm.hpp
index af8d75fb..aea1eb36 100644
--- a/src/tangara/ui/ui_fsm.hpp
+++ b/src/tangara/ui/ui_fsm.hpp
@@ -67,6 +67,7 @@ class UiState : public tinyfsm::Fsm<UiState> {
void react(const audio::VolumeChanged&);
void react(const audio::VolumeBalanceChanged&);
void react(const audio::VolumeLimitChanged&);
+ void react(const audio::RemoteVolumeChanged& ev);
void react(const system_fsm::KeyLockChanged&);
void react(const system_fsm::SamdUsbStatusChanged&);