ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
preferences.h
Go to the documentation of this file.
1#pragma once
2#ifdef USE_LIBRETINY
3
6#include <flashdb.h>
7
8namespace esphome::libretiny {
9
10struct NVSData;
11
12class LibreTinyPreferences final : public PreferencesMixin<LibreTinyPreferences> {
13 public:
15 void open();
16#ifdef USE_LIBRETINY_RTC_PREFERENCES
18#else
19 // Without rtc storage every preference lives in flash; inline so builds that don't use rtc pay nothing
21 return this->make_preference(length, type);
22 }
23#endif
26 bool load_from_key(uint32_t type, uint8_t *data, size_t len);
27 bool sync();
28 bool reset();
29
30 struct fdb_kvdb db;
31 struct fdb_blob blob;
32
33 protected:
35 bool is_changed_(fdb_kvdb_t db, const NVSData &to_save, const char *key_str);
36#ifdef USE_LIBRETINY_RTC_PREFERENCES
38#endif
39};
40
42
43} // namespace esphome::libretiny
44
45DECLARE_PREFERENCE_ALIASES(esphome::libretiny::LibreTinyPreferences)
46
47#endif // USE_LIBRETINY
CRTP mixin providing type-safe template make_preference<T>() helpers.
ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)
bool load_from_key(uint32_t type, uint8_t *data, size_t len)
One-shot read of a stored preference by key, without allocating a backend.
bool is_changed_(fdb_kvdb_t db, const NVSData &to_save, const char *key_str)
LibreTinyPreferenceBackend make_backend_(uint32_t type, bool rtc=false)
uint8_t type
const void size_t len
Definition hal.h:68
static void uint32_t
uint16_t length
Definition tt21100.cpp:0