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.