From 4247c9fe7d25c921fbfc73fc50e849c8780e7ad6 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 29 Aug 2023 16:07:56 +1000 Subject: store the screen brightness in nvs --- src/drivers/include/nvs.hpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/drivers/include') diff --git a/src/drivers/include/nvs.hpp b/src/drivers/include/nvs.hpp index 913ad51e..bc88f88d 100644 --- a/src/drivers/include/nvs.hpp +++ b/src/drivers/include/nvs.hpp @@ -7,35 +7,44 @@ #pragma once #include +#include #include #include "esp_err.h" #include "nvs.h" #include "bluetooth_types.hpp" +#include "tasks.hpp" namespace drivers { class NvsStorage { public: - static auto Open() -> NvsStorage*; + static auto OpenSync() -> NvsStorage*; - auto SchemaVersion() -> uint8_t; - - auto PreferredBluetoothDevice() -> std::optional; - auto PreferredBluetoothDevice(std::optional) -> void; + auto PreferredBluetoothDevice() + -> std::future>; + auto PreferredBluetoothDevice(std::optional) + -> std::future; enum class Output : uint8_t { kHeadphones = 0, kBluetooth = 1, }; - auto OutputMode() -> Output; - auto OutputMode(Output) -> void; + auto OutputMode() -> std::future; + auto OutputMode(Output) -> std::future; + + auto ScreenBrightness() -> std::future; + auto ScreenBrightness(uint_fast8_t) -> std::future; - explicit NvsStorage(nvs_handle_t); + explicit NvsStorage(std::unique_ptr, nvs_handle_t); ~NvsStorage(); private: + auto DowngradeSchemaSync() -> bool; + auto SchemaVersionSync() -> uint8_t; + + std::unique_ptr writer_; nvs_handle_t handle_; }; -- cgit v1.2.3