I'm currently doing a project for a device that has A LOT of parameters. It's not the first time I'll be doing parameters, but experience has thought me that sooner or later all literals you've put in the software require to be changed for some custom application. To prevent creating a mess with different custom software versions, the idea has come up to make all things a parameter.
Variable Frequency Drives also offer this, hundreds or parameters sorted by number and category. Some hidden from end-users.
However, having dealt with a few parameters, I have not with dozens. What would be an expandable way to handle parameters?
I could store then as an INI file in flash. But that has a rather large ROM footprint for a small micro. List of keys, their type, their range, the number parsers, the default ini.
The device does not feature a user interface. This will be made externally, on pc or smartphone.
Currently I'm thinking of creating a structure with all the parameters in it. And reserve three blocks of flash to put them in.
- One "defaults" block.
- One "active" block.
- One "previous" block.
Since flash has to be mass erased, new settings would be written to the current "previous" block, and a byte in the "active" block would be written to null to indicate it has been deactivated. On boot the correct block is loaded into the pointer.
This would also support reverting the settings.
Obviously, the parameters would be only changed during commissioning of the device. For runtime parameters, of which there are not that many, there is SRAM and FRAM.
Any critics? (there must be, criticism is what we're best at)
Anyone dealt with something like this before?