From b192975cb1eeb4e6b7c7bf53cdf42701c55f034a Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 22 Sep 2023 15:48:41 +1000 Subject: make bluetooth pairing ui functional --- src/ui/include/screen_settings.hpp | 22 +++++++++++++++++++++- src/ui/include/ui_fsm.hpp | 9 +++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'src/ui/include') diff --git a/src/ui/include/screen_settings.hpp b/src/ui/include/screen_settings.hpp index caa23fd4..4e1936a2 100644 --- a/src/ui/include/screen_settings.hpp +++ b/src/ui/include/screen_settings.hpp @@ -8,9 +8,12 @@ #include #include +#include #include #include +#include "bluetooth.hpp" +#include "bluetooth_types.hpp" #include "display.hpp" #include "index.hpp" #include "lvgl.h" @@ -28,7 +31,24 @@ class Settings : public MenuScreen { class Bluetooth : public MenuScreen { public: - Bluetooth(); + Bluetooth(drivers::Bluetooth& bt, drivers::NvsStorage& nvs); + + auto ChangeEnabledState(bool enabled) -> void; + auto RefreshDevicesList() -> void; + auto OnDeviceSelected(size_t index) -> void; + + private: + auto RemoveAllDevices() -> void; + auto AddPreferredDevice(const drivers::bluetooth::Device&) -> void; + auto AddDevice(const drivers::bluetooth::Device&) -> void; + + drivers::Bluetooth& bt_; + drivers::NvsStorage& nvs_; + + lv_obj_t* devices_list_; + lv_obj_t* preferred_device_; + + std::list macs_in_list_; }; class Headphones : public MenuScreen { diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp index 5363e1a4..9980dac6 100644 --- a/src/ui/include/ui_fsm.hpp +++ b/src/ui/include/ui_fsm.hpp @@ -17,6 +17,7 @@ #include "nvs.hpp" #include "relative_wheel.hpp" #include "screen_playing.hpp" +#include "screen_settings.hpp" #include "service_locator.hpp" #include "tinyfsm.hpp" @@ -72,6 +73,7 @@ class UiState : public tinyfsm::Fsm { virtual void react(const system_fsm::DisplayReady&) {} virtual void react(const system_fsm::BootComplete&) {} virtual void react(const system_fsm::StorageMounted&) {} + virtual void react(const system_fsm::BluetoothDevicesChanged&) {} protected: void PushScreen(std::shared_ptr); @@ -112,6 +114,7 @@ class Onboarding : public UiState { }; class Browse : public UiState { + public: void entry() override; void react(const internal::RecordSelected&) override; @@ -122,10 +125,16 @@ class Browse : public UiState { void react(const internal::ShowSettingsPage&) override; void react(const system_fsm::StorageMounted&) override; + void react(const system_fsm::BluetoothDevicesChanged&) override; + using UiState::react; + + private: + std::weak_ptr bluetooth_screen_; }; class Playing : public UiState { + public: void entry() override; void exit() override; -- cgit v1.2.3