I have a ESP32, programmed using Arduino IDE.
In my code I have 2 variables: sName (string) and nScore (double).
This pair of variables, needs to be written to the EEPROM into the higscore namespace. So far it would be easy, open the namespace, and write the values..
but here comes the tricky part: The namespace highscore has 20 values: 10 names and 10 scores. I need to write the value to the namespace only if it is higher than those already present, and to add it to the correct spot in the high score table, shifting all the other values.
How should I do this? Currently I am thinking of loading all the values on startup and storing it in 2 arrays. Then whenever something is changed in the array, write it down.
But I am not sure that this is the proper way of doing this.
SPIFFS.open("highscore.json"), and ArduinoJson lets you represent your data in a format that's easy for you to understand. Json for saving basic types on an embedded processor's flash is usually a waste, but it sounds like this isn't data that changes every millisecond, and most ESP32 projects have tons of unused resources left over when it comes to RAM. - Selali Adobor