summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-08 16:58:30 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-08 16:58:30 +1000
commitb0d745d02dcfd6ab9b1ad14e9060b39bf9ad7bb8 (patch)
treea6ca6390852d64375524d480e9586a58c64cef08 /src/drivers
parent64d9cec8b074eaf9280bc92e38656a35a4e5e452 (diff)
downloadtangara-fw-b0d745d02dcfd6ab9b1ad14e9060b39bf9ad7bb8.tar.gz
Flesh out onboarding a little, and add a way to get into it
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/include/nvs.hpp3
-rw-r--r--src/drivers/nvs.cpp16
2 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/include/nvs.hpp b/src/drivers/include/nvs.hpp
index d7b3dfdd..91b68bc4 100644
--- a/src/drivers/include/nvs.hpp
+++ b/src/drivers/include/nvs.hpp
@@ -43,6 +43,9 @@ class NvsStorage {
auto AmpCurrentVolume() -> std::future<uint16_t>;
auto AmpCurrentVolume(uint16_t) -> std::future<bool>;
+ auto HasShownOnboarding() -> std::future<bool>;
+ auto HasShownOnboarding(bool) -> std::future<bool>;
+
explicit NvsStorage(std::unique_ptr<tasks::Worker>, nvs_handle_t);
~NvsStorage();
diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp
index 7bd1afe2..0a466b16 100644
--- a/src/drivers/nvs.cpp
+++ b/src/drivers/nvs.cpp
@@ -30,6 +30,7 @@ static constexpr char kKeyOutput[] = "out";
static constexpr char kKeyBrightness[] = "bright";
static constexpr char kKeyAmpMaxVolume[] = "hp_vol_max";
static constexpr char kKeyAmpCurrentVolume[] = "hp_vol";
+static constexpr char kKeyOnboarded[] = "intro";
auto NvsStorage::OpenSync() -> NvsStorage* {
esp_err_t err = nvs_flash_init();
@@ -187,4 +188,19 @@ auto NvsStorage::AmpCurrentVolume(uint16_t val) -> std::future<bool> {
});
}
+auto NvsStorage::HasShownOnboarding() -> std::future<bool> {
+ return writer_->Dispatch<bool>([&]() -> bool {
+ uint8_t out = true;
+ nvs_get_u8(handle_, kKeyOnboarded, &out);
+ return out;
+ });
+}
+
+auto NvsStorage::HasShownOnboarding(bool val) -> std::future<bool> {
+ return writer_->Dispatch<bool>([&]() {
+ nvs_set_u8(handle_, kKeyOnboarded, val);
+ return nvs_commit(handle_) == ESP_OK;
+ });
+}
+
} // namespace drivers