On storing sensitivity presets and other settings in the onboard flash:
The flash memory on my MCU comes in 512 byte pages. You can write one byte at a time, but you can only change 1s into 0s with that operation. To change 0s into 1s you have to erase the whole page. I think this means if I write 0b00000001 to an address, and later write 0b00000010, the value stored will be 0b00000011. If it works like that, I might use the first ~8 bytes of the page as an index, write one bit in the index every time I update a preset, to show which address contains the most recent value. Then I only need to erase after I've filled the whole page, cutting the program erase cycles down to ~1/63 of what it would be using a static address. If there's an error I'll just revert back to the default array of presets.
Or I could just traverse the page until there aren't any more entries, and use the last one. I only really have to read from it when I first plug in the mouse, so I'll probably end up doing this, I'll just keep the current index and values in RAM.
Chip is specified for 20k p/e cycles minimum, so I shouldn't have any problem with endurance using either of these methods.
Last edited by TranquilTempest; 10-14-2019 at 03:09 AM.