A stylistic question regarding the use of ESP32 Preferences

I have an application where I am using Preferences for the first time instead of the EEPROM process. No problems getting it to work but I do have a question about style or best practices.

In the application, the the namespace is used for configuration settings for the different functions in the application. When the device is being set up, changes and entries will be frequent but once finished, changes will be only occasionally.

I have a routine that gets them all in when the application first starts. That routine ends with preferences.end(); The question I have is how to best put new values in. Once the user changes one of these settings, I could put code locally to begin the correct namespace, put the changed value, and then end Preferences. Alternatively, when any setting is changed, I could call just one routine that opens all the namespaces and puts all the setting values whether or not they have changed and then close the Preferences.

Any thoughts on the pros and cons with these approaches?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.