diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-03 15:00:28 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-03 15:00:28 +1100 |
| commit | c851b789faf71d0ef2092ae7d8cd3190c13d85c9 (patch) | |
| tree | 32a3ca469063dcf4a25e6d6767de50f5d8c535e8 /src/drivers/nvs.cpp | |
| parent | 09f129662e41108fd86255c02623a38e07cbbb27 (diff) | |
| download | tangara-fw-c851b789faf71d0ef2092ae7d8cd3190c13d85c9.tar.gz | |
Write up the new input modes to NVS and settings
Diffstat (limited to 'src/drivers/nvs.cpp')
| -rw-r--r-- | src/drivers/nvs.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp index 16a9609d..ffaa0a5e 100644 --- a/src/drivers/nvs.cpp +++ b/src/drivers/nvs.cpp @@ -31,6 +31,7 @@ static constexpr char kKeyBrightness[] = "bright"; static constexpr char kKeyAmpMaxVolume[] = "hp_vol_max"; static constexpr char kKeyAmpCurrentVolume[] = "hp_vol"; static constexpr char kKeyOnboarded[] = "intro"; +static constexpr char kKeyPrimaryInput[] = "in_pri"; auto NvsStorage::OpenSync() -> NvsStorage* { esp_err_t err = nvs_flash_init(); @@ -166,4 +167,27 @@ auto NvsStorage::HasShownOnboarding(bool val) -> bool { return nvs_commit(handle_) == ESP_OK; } +auto NvsStorage::PrimaryInput() -> InputModes { + uint8_t out = 3; + nvs_get_u8(handle_, kKeyPrimaryInput, &out); + switch (out) { + case static_cast<uint8_t>(InputModes::kButtonsOnly): + return InputModes::kButtonsOnly; + case static_cast<uint8_t>(InputModes::kButtonsWithWheel): + return InputModes::kButtonsWithWheel; + case static_cast<uint8_t>(InputModes::kDirectionalWheel): + return InputModes::kDirectionalWheel; + case static_cast<uint8_t>(InputModes::kRotatingWheel): + return InputModes::kRotatingWheel; + default: + return InputModes::kRotatingWheel; + } +} + +auto NvsStorage::PrimaryInput(InputModes mode) -> bool { + uint8_t as_int = static_cast<uint8_t>(mode); + nvs_set_u8(handle_, kKeyPrimaryInput, as_int); + return nvs_commit(handle_) == ESP_OK; +} + } // namespace drivers |
