Hi! I'm don't know what's the best method to deal with my problem
I need to save some of my variables (integer/float) in term of programs.
For example:
program[0] {int quantity=5, float speed =3.4f,...}
program[1] {int quantity=2, float speed =19.2f,...}
program[n] {int quantity=A, float speed =B.xf,...}
So can choose which program to use by indexing the N index in my main code.
I have read the documentation about SPI flash (not totally understand everything) but there is no example code for the SPI flash in ESP IDF. The only example that I understand is NVS flash that use key pair/value method, so I guess if I have 10 values then 10 pairs? (which is very manual thing to do).
I suppose the easiest way to me is some kind of struct then we create a array contains the structs "program" then we set the value in the corresponding structs then save everything to flash - or any possible storage device in ESP32. Please show me the best way to do so (I am using ESP32-WROOM-32E module).
Thank you!
[HELP] Saving sets of program parameters with ESP IDF
-
- Posts: 8926
- Joined: Thu Nov 26, 2015 4:08 am
Re: [HELP] Saving sets of program parameters with ESP IDF
There's multiple ways. Raw flash is one, but you'd be lacking wear leveling. NVS indeed is another one, you could either store the programs as a blob or have keys like 'quantity05' for the quantity field of program 5, or even have a separate namespace for each program (open namespace 'program05', get key 'quantity'). As a third alternative, you could have a spiffs file system and save the programs as files there. There's not really a 'best' solution, use whatever fits your taste.
Who is online
Users browsing this forum: No registered users and 115 guests