From b0d745d02dcfd6ab9b1ad14e9060b39bf9ad7bb8 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 8 Sep 2023 16:58:30 +1000 Subject: Flesh out onboarding a little, and add a way to get into it --- src/drivers/nvs.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/drivers/nvs.cpp') 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 { }); } +auto NvsStorage::HasShownOnboarding() -> std::future { + return writer_->Dispatch([&]() -> bool { + uint8_t out = true; + nvs_get_u8(handle_, kKeyOnboarded, &out); + return out; + }); +} + +auto NvsStorage::HasShownOnboarding(bool val) -> std::future { + return writer_->Dispatch([&]() { + nvs_set_u8(handle_, kKeyOnboarded, val); + return nvs_commit(handle_) == ESP_OK; + }); +} + } // namespace drivers -- cgit v1.2.3