diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-02-05 14:58:40 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-02-05 14:58:40 +1100 |
| commit | e07330990775f1037fc54da18d9c97e06368b18a (patch) | |
| tree | d8cef5cacd6e77c1f27d82b278a8e50dedd4f4c4 /src | |
| parent | 0f03efe868f4a7910678a0a729f437a2fe8986b7 (diff) | |
| download | tangara-fw-e07330990775f1037fc54da18d9c97e06368b18a.tar.gz | |
Properly persist bluetooth mode changes
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio/audio_fsm.cpp | 1 | ||||
| -rw-r--r-- | src/ui/ui_fsm.cpp | 31 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp index e37c887b..b1c5c2b8 100644 --- a/src/audio/audio_fsm.cpp +++ b/src/audio/audio_fsm.cpp @@ -113,7 +113,6 @@ void AudioState::react(const SetVolumeBalance& ev) { } void AudioState::react(const OutputModeChanged& ev) { - // TODO: handle SetInUse ESP_LOGI(kTag, "output mode changed"); auto new_mode = sServices->nvs().OutputMode(); sOutput->SetMode(IAudioOutput::Modes::kOff); diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index abe88460..b3546d55 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -77,19 +77,24 @@ lua::Property UiState::sBatteryPct{0}; lua::Property UiState::sBatteryMv{0}; lua::Property UiState::sBatteryCharging{false}; -lua::Property UiState::sBluetoothEnabled{ - false, [](const lua::LuaValue& val) { - if (!std::holds_alternative<bool>(val)) { - return false; - } - if (std::get<bool>(val)) { - sServices->bluetooth().Enable(); - sServices->bluetooth().SetDeviceDiscovery(true); - } else { - sServices->bluetooth().Disable(); - } - return true; - }}; +lua::Property UiState::sBluetoothEnabled { + false, [](const lua::LuaValue& val) { + if (!std::holds_alternative<bool>(val)) { + return false; + } + if (std::get<bool>(val)) { + sServices->bluetooth().Enable(); + sServices->bluetooth().SetDeviceDiscovery(true); + sServices->nvs().OutputMode(drivers::NvsStorage::Output::kBluetooth); + } else { + sServices->bluetooth().Disable(); + sServices->nvs().OutputMode(drivers::NvsStorage::Output::kHeadphones); + } + events::Audio().Dispatch(audio::OutputModeChanged{}); + return true; + } +}; + lua::Property UiState::sBluetoothConnected{false}; lua::Property UiState::sBluetoothPairedDevice{ std::monostate{}, [](const lua::LuaValue& val) { |
