PersistentStorage Patch_SM DaisyDuino Example

Hi,

I have prototyped a sketch that stores values between power cycles using a Pro Micro and EEPROM. I’m trying to move that sketch over to Patch_SM and I am getting nowhere since EEPROM doesn’t work with STM32. Is it even possible to store values on Patch_SM without an SD card? Should I be using PersistentStorage? If so, a simple example for Patch_SM and DaisyDuino that simply stores and loads a single value would be tremendously helpful. EEPROM is just so easy…

Any help is much appreciated.

There was a PR that was merged for using PersistenStorage with the DaisyDuino. We haven’t had a chance make an example yet but the PR itself shows how it’s used: PersistentStorage, QSPI external flash, CpuLoadMeter support & ReverbSc extras by snail23 · Pull Request #56 · electro-smith/DaisyDuino · GitHub

I hope this helps!

Thanks for the quick reply @Takumi_Ogata !

Just to make sure, this works with built-in storage on board the Patch SM? No SD card or other external device required?

@Takumi_Ogata I was able to get it working on Patch SM by following the PR link you shared above.

Thanks once again for the help! :smiley:

Something that is still stumping me is how to declare a PersistentStorage variable as a global variable, since it needs to be passed the qspi, which needs to be configured in setup first. I want to make changes to the stored values as a user makes changes in a menu.

Move the following line outside of Setup():

PersistentStorage storage(qspi);

Gosh I really should have just tried that. :persevere: I assumed it wouldn’t work because qspi was being passed as an argument when declaring the storage variable. Yikes. Live and learn. Thanks for the reply @tele_player

Did it work?

If I recall correctly, that code might need some work to handle the real-world case of save/restore state of several variables. It depends on the saved object having methods for operator== and operator!=, so it can tell if the current data matches stored data.