struct EE {
int devID = 0XEFBEADDA; //load a default value for the first init
short step; //at the first init will be equal to zero
};
EEBoom<EE> ee;
void setup() {
ee.begin(); //will use two default sectors
}
void loop() {
ee.data.step++; //change data in RAM
ee.commit(); //fix it in the flash memory
delay(1000);
}
Yes, this library has advantages.
We don't use NVS or LittleFs to put data in memory. So this works for both esp8266 and esp32 and can also be ported (in the future) to other platforms as I mentioned above. The data in memory is stored with minimal overhead, so if you need to store 1 byte, you don't need to rewrite 32 bytes every time commit() (NVS) or move the whole file to a new page (LittleFs).
Either way, you have complete control over the write and can be sure of the life of your flash memory. EEBoom allows you to create multiple objects in arbitrary areas of flash - you are not limited to 5-6 sector nvs.
This is the first thing that comes to mind. Ask questions, examples - if you need we can try to compare in more detail.
Thanks for the advice. But I didn't want to create another eeprom manager or like that.... In the end the main thing is functionality. If it's really convenient and easy - it doesn't matter what it's called.
Why do you think that more economical and careful memory usage is not an advantage? You can save more and overwrite it very often.
I realize that people are used to NVS, LIttleFs and preferences. But this is a more native approach. It is not only applicable for espressif platforms. I think it would be nice to have this kind of storage on blue pill? And it's already working) So over the long haul, if people try this library - it will be very popular and in demand.
We'll keep LittleFs for files, and NVS for esp32.
I would not associate the name EEBoom with using the EEPROM and nor would most people who come across it I suspect. Most users have no reason to go looking for am alternative to the supplied libraries so how are you going to alert them to the existence of EEBoom ?
To me that is a feature. What benefit does it offer and is it worth the effort of learning how to use yet another library ?
This is undoubtedly true, but the name yetAnotherEEpromLib isn't as appealing and also doesn't do a good job of describing the benefits... I bet on the wow effect in the name and promoting the code in the community with forums and all that.
I have an exemplary task for this system - I need to track the time of device operation with the accuracy of 5-10 seconds (this is a task from a real project). That is, we need to save a new tag every 5-10 seconds.
Try to calculate the lifetime of flash memory when using NVS, and even more so LittleFS.
By the way EEBoom has a built-in tool for calculating flash memory life time:
ee.printInfo(mnt);
In this case, among other things, will be displayed information about the life time of flash memory with current settings (number of sectors and structure size) when writing 1 time in mnt minutes.
Not bad)
But I think we need to get feedback from people first. Nobody searches for a library by its name. Usually a person goes to google and searches for something like esp8266 eeprom. It is not bad if in the first ten links will be displayed this page on the forum. But it will take some time.
When and if the library becomes popular - we can vote for the best name.
And for starters, UKHeliBob, if you have any suitable projects, I could help with integration for testing purposes. That way you won't have to learn a new library)
Not ganging up on you in any way here but I agree with @UKHeliBob … the name is not good. It almost makes me think your code is going to explode my eeprom or nvs….
One comment from a non proficient coder here. The code seems very complicated for a beginner to use and The basic example shows how to commit to memory but then what?? How would a person “read” or “retrieve” the data/variable stored in memory? I think personnally you need more examples, more details in your comments as well to explain for basic people like me.
First look at eeprom.h and preferences.h for me and i know how I should code it to try and learn. First look at yours and i am confused and have many questions.
I don’t doubt your coding skills and what you claim as I am not a coder BUT
honest feedback is good right??
Of course! Thanks for the feedback. But I'm actually a bit confused...
The thing is that the Basic example really is the minimal code to retrieve and store the data... The data is extracted from the "eeprom" automatically when you call begin() (usually at the start of program).
At that point, the library will either find valid data in one of the flash memory pages, or load the default data that is specified in the structure (as in the example).
The data is then available via field data of your object.
So this is really complete working code that I use all the time in my projects.
I seem to have a hard time looking at it through the eyes of a user.... How would you suggest to write or describe this example so that people understand everything at a glance?
That is about as non intuitive as you could make it. To my mind the standard EEPROM library has the syntax about right.
Your library might need a begin() function and it could, perhaps have an option to call it with a parameter indicating what is to be loaded, but automatic loading should not be the default
None of it is very intuitive is all. I don’t know how to say it otherwise, sorry. I mean, if the function reads data from the “eeprom” then the function should be called something other then “begin” and your comments should reflect and explain that as well. Small Example of change that would help quote
“//will use two default sectors and read data/variable from eeprom
Anyway, I have four kids and they need to go to bed . Keep up the good work, good luck and good night