summaryrefslogtreecommitdiff
path: root/src/drivers/nvs.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-08-16 10:22:30 +1000
committerjacqueline <me@jacqueline.id.au>2023-08-16 10:22:30 +1000
commit62dce8d9fcc139ca6dc2041c86723d19faab304f (patch)
tree91cf03100f8143b2ab6769e39bae93c98bce6df3 /src/drivers/nvs.cpp
parent544b0013b104a6584660724ccd502adcccd7ca6c (diff)
downloadtangara-fw-62dce8d9fcc139ca6dc2041c86723d19faab304f.tar.gz
Save current output mode to nvs
Diffstat (limited to 'src/drivers/nvs.cpp')
-rw-r--r--src/drivers/nvs.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp
index 8c7e54a8..d2110764 100644
--- a/src/drivers/nvs.cpp
+++ b/src/drivers/nvs.cpp
@@ -22,6 +22,7 @@ static constexpr uint8_t kSchemaVersion = 1;
static constexpr char kKeyVersion[] = "ver";
static constexpr char kKeyBluetooth[] = "bt";
+static constexpr char kKeyOutput[] = "out";
auto NvsStorage::Open() -> NvsStorage* {
esp_err_t err = nvs_flash_init();
@@ -81,6 +82,7 @@ auto NvsStorage::PreferredBluetoothDevice()
}
return out;
}
+
auto NvsStorage::PreferredBluetoothDevice(
std::optional<bluetooth::mac_addr_t> addr) -> void {
if (!addr) {
@@ -92,4 +94,21 @@ auto NvsStorage::PreferredBluetoothDevice(
nvs_commit(handle_);
}
+auto NvsStorage::OutputMode() -> Output {
+ uint8_t out = 0;
+ nvs_get_u8(handle_, kKeyOutput, &out);
+ switch (out) {
+ case static_cast<uint8_t>(Output::kBluetooth):
+ return Output::kHeadphones;
+ case static_cast<uint8_t>(Output::kHeadphones):
+ default:
+ return Output::kHeadphones;
+ }
+}
+
+auto NvsStorage::OutputMode(Output out) -> void {
+ nvs_set_u8(handle_, kKeyOutput, static_cast<uint8_t>(out));
+ nvs_commit(handle_);
+}
+
} // namespace drivers