summaryrefslogtreecommitdiff
path: root/src/drivers/include/nvs.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-08-29 16:07:56 +1000
committerjacqueline <me@jacqueline.id.au>2023-08-29 16:07:56 +1000
commit4247c9fe7d25c921fbfc73fc50e849c8780e7ad6 (patch)
treeb8288c7772010edfb4a398596bef8fd35b771a95 /src/drivers/include/nvs.hpp
parent773f2857678727f416a67a3a5ae71bd5b6761078 (diff)
downloadtangara-fw-4247c9fe7d25c921fbfc73fc50e849c8780e7ad6.tar.gz
store the screen brightness in nvs
Diffstat (limited to 'src/drivers/include/nvs.hpp')
-rw-r--r--src/drivers/include/nvs.hpp25
1 files changed, 17 insertions, 8 deletions
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 <stdint.h>
+#include <memory>
#include <optional>
#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<bluetooth::mac_addr_t>;
- auto PreferredBluetoothDevice(std::optional<bluetooth::mac_addr_t>) -> void;
+ auto PreferredBluetoothDevice()
+ -> std::future<std::optional<bluetooth::mac_addr_t>>;
+ auto PreferredBluetoothDevice(std::optional<bluetooth::mac_addr_t>)
+ -> std::future<bool>;
enum class Output : uint8_t {
kHeadphones = 0,
kBluetooth = 1,
};
- auto OutputMode() -> Output;
- auto OutputMode(Output) -> void;
+ auto OutputMode() -> std::future<Output>;
+ auto OutputMode(Output) -> std::future<bool>;
+
+ auto ScreenBrightness() -> std::future<uint_fast8_t>;
+ auto ScreenBrightness(uint_fast8_t) -> std::future<bool>;
- explicit NvsStorage(nvs_handle_t);
+ explicit NvsStorage(std::unique_ptr<tasks::Worker>, nvs_handle_t);
~NvsStorage();
private:
+ auto DowngradeSchemaSync() -> bool;
+ auto SchemaVersionSync() -> uint8_t;
+
+ std::unique_ptr<tasks::Worker> writer_;
nvs_handle_t handle_;
};