Skip to content

Commit 8d22dfe

Browse files
authored
Add the preferences documentation
1 parent 097a690 commit 8d22dfe

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

content/arduino-libraries/io-abstraction/eeprom-impl-seamless-8-and-32-bit.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ Note that on the ESP range of devices, you'll need to call `EEPROM.begin(size)`
8383

8484
ArduinoEEPROMAbstraction eepromWrapper(EEPROM);
8585

86+
### EspPreferencesEeprom for ESP32 Preferences storage
87+
88+
Requires ESP32 framework with Preferences library available for use. Note that in order to write back what's in memory you need to call `commit` to do the actual write.
89+
90+
This class wraps the preferences API that's available on ESP32 Arduino framework. To use the wrapper first include:
91+
92+
#include <esp32/EspPreferencesEeprom.h>
93+
94+
Then construct globally as follows:
95+
96+
EspPreferencesEeprom prefsStore(myNamespace, size);
97+
98+
Where `myNamespace` is the namespace to use with preferences, and `size` is the size of the byte array it will create.
99+
100+
Once you've finished writing values to it, flush the values out to storage as follows:
101+
102+
prefsStore.commit();
103+
104+
A word of caution, do not call commit too often, this storage is probably in FLASH, and has limited write cycles.
105+
86106
### HalStm32EepromAbstraction for STM32 applications
87107

88108
Requires version 1.8 of IoAbstraction.
@@ -166,4 +186,4 @@ Firstly, never call save in the menu item callback, *if using a rotary encoder t
166186
* Provide a save option somewhere that performs the save function.
167187
* Have a task manager event or task that listens for changes and saves a maximum of once every N minutes, where N is as large as you can tolerate. This may still write to EEPROM too frequently.
168188

169-
[Go back to the IoAbstraction page]({{< relref "io-abstraction.md" >}})
189+
[Go back to the IoAbstraction page]({{< relref "io-abstraction.md" >}})

0 commit comments

Comments
 (0)