summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/include/drivers/nvs.hpp5
-rw-r--r--src/drivers/nvs.cpp14
2 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/include/drivers/nvs.hpp b/src/drivers/include/drivers/nvs.hpp
index e147c8c7..9725bb0f 100644
--- a/src/drivers/include/drivers/nvs.hpp
+++ b/src/drivers/include/drivers/nvs.hpp
@@ -138,6 +138,9 @@ class NvsStorage {
auto PrimaryInput() -> InputModes;
auto PrimaryInput(InputModes) -> void;
+ auto QueueRepeatMode() -> uint8_t;
+ auto QueueRepeatMode(uint8_t) -> void;
+
auto DbAutoIndex() -> bool;
auto DbAutoIndex(bool) -> void;
@@ -173,6 +176,8 @@ class NvsStorage {
Setting<uint8_t> db_auto_index_;
+ Setting<uint8_t> queue_repeat_mode_;
+
util::LruCache<10, bluetooth::mac_addr_t, uint8_t> bt_volumes_;
bool bt_volumes_dirty_;
diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp
index d004201b..6c916e60 100644
--- a/src/drivers/nvs.cpp
+++ b/src/drivers/nvs.cpp
@@ -41,6 +41,7 @@ static constexpr char kKeyDisplayRows[] = "disprows";
static constexpr char kKeyHapticMotorType[] = "hapticmtype";
static constexpr char kKeyLraCalibration[] = "lra_cali";
static constexpr char kKeyDbAutoIndex[] = "dbautoindex";
+static constexpr char kKeyQueueRepeatMode[] = "queue_rpt";
static constexpr char kKeyFastCharge[] = "fastchg";
static auto nvs_get_string(nvs_handle_t nvs, const char* key)
@@ -278,6 +279,7 @@ NvsStorage::NvsStorage(nvs_handle_t handle)
bt_preferred_(kKeyBluetoothPreferred),
bt_names_(kKeyBluetoothNames),
db_auto_index_(kKeyDbAutoIndex),
+ queue_repeat_mode_(kKeyQueueRepeatMode),
bt_volumes_(),
bt_volumes_dirty_(false) {}
@@ -304,6 +306,7 @@ auto NvsStorage::Read() -> void {
bt_preferred_.read(handle_);
bt_names_.read(handle_);
db_auto_index_.read(handle_);
+ queue_repeat_mode_.read(handle_);
readBtVolumes();
}
@@ -325,6 +328,7 @@ auto NvsStorage::Write() -> bool {
bt_preferred_.write(handle_);
bt_names_.write(handle_);
db_auto_index_.write(handle_);
+ queue_repeat_mode_.write(handle_);
writeBtVolumes();
return nvs_commit(handle_) == ESP_OK;
}
@@ -566,6 +570,16 @@ auto NvsStorage::PrimaryInput(InputModes mode) -> void {
input_mode_.set(static_cast<uint8_t>(mode));
}
+auto NvsStorage::QueueRepeatMode() -> uint8_t {
+ std::lock_guard<std::mutex> lock{mutex_};
+ return queue_repeat_mode_.get().value_or(0);
+}
+
+auto NvsStorage::QueueRepeatMode(uint8_t mode) -> void {
+ std::lock_guard<std::mutex> lock{mutex_};
+ queue_repeat_mode_.set(mode);
+}
+
auto NvsStorage::DbAutoIndex() -> bool {
std::lock_guard<std::mutex> lock{mutex_};
return db_auto_index_.get().value_or(true);