From 7cdcd44e0ca10ebdc796638190ed1d9b45d99ef0 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 15 Jan 2024 12:31:20 +1100 Subject: Begin migration of remaining screens to Lua --- src/drivers/include/gpios.hpp | 2 +- src/drivers/include/nvs.hpp | 3 +++ src/drivers/nvs.cpp | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/include/gpios.hpp b/src/drivers/include/gpios.hpp index 55486be7..fffd1f75 100644 --- a/src/drivers/include/gpios.hpp +++ b/src/drivers/include/gpios.hpp @@ -79,7 +79,7 @@ class IGpios { */ virtual auto Get(Pin) const -> bool = 0; - virtual auto IsLocked() const -> bool { return Get(Pin::kKeyLock); } + virtual auto IsLocked() const -> bool { return !Get(Pin::kKeyLock); } }; class Gpios : public IGpios { diff --git a/src/drivers/include/nvs.hpp b/src/drivers/include/nvs.hpp index 46a3d154..b82013b5 100644 --- a/src/drivers/include/nvs.hpp +++ b/src/drivers/include/nvs.hpp @@ -41,6 +41,9 @@ class NvsStorage { auto AmpCurrentVolume() -> uint16_t; auto AmpCurrentVolume(uint16_t) -> bool; + auto AmpLeftBias() -> int_fast8_t; + auto AmpLeftBias(int_fast8_t) -> bool; + auto HasShownOnboarding() -> bool; auto HasShownOnboarding(bool) -> bool; diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp index c8a9a7c7..c8d4d636 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 kKeyAmpLeftBias[] = "hp_bias"; static constexpr char kKeyOnboarded[] = "intro"; static constexpr char kKeyPrimaryInput[] = "in_pri"; @@ -156,6 +157,17 @@ auto NvsStorage::AmpCurrentVolume(uint16_t val) -> bool { return nvs_commit(handle_) == ESP_OK; } +auto NvsStorage::AmpLeftBias() -> int_fast8_t { + int8_t out = 0; + nvs_get_i8(handle_, kKeyAmpLeftBias, &out); + return out; +} + +auto NvsStorage::AmpLeftBias(int_fast8_t val) -> bool { + nvs_set_i8(handle_, kKeyAmpLeftBias, val); + return nvs_commit(handle_) == ESP_OK; +} + auto NvsStorage::HasShownOnboarding() -> bool { uint8_t out = false; nvs_get_u8(handle_, kKeyOnboarded, &out); -- cgit v1.2.3