I’m writing an app where I want to cache some online data locally on the Tufty (just a small JSON file). It seems I can’t do that (getting the JSON error 30 - indicating read only file system). Is there any setting that would allow me to do that - or some “special” folder? I haven’t seen anything in the badgeware.io/docs that mentions file saving - so curious if I missed that. Thanks!
Oh… curious… digging into the example apps (clock for instance) I see there is a badgeware.state construct which appears to survive between app runs (just guessing). Can’t find any documentation on the limitations of that. I don’t need a lot of space.. but.. would be nice to know how much I can push that.
Umm.. yep.. my edit mentions I discovered State. Working great for my needs right now. Phew! Thanks for the link to the github class. I was looking for more of a “this is how to use it / these are the limitations” - which don’t seem to exist. Either way - thanks for the response. Appreciated!
There’s a docs page on State waiting to go up, but the basics are pretty easy to see from the module in GitHub -
State.save(name, data) - saves data to a json file called name in /state, where data is a dictionary containing simple types
State.load(name, dict) - loads from the name json file into the specified dictionary. If there’s no such file, it creates one using the current contents of dict.
State.delete(name) - deletes the specified state file.
It’s worth also mentioning that you should be able to use all of the usual MicroPython read / write functions in /state, for other kinds of data.
Thanks for that. I have things running well so far (storing ISS pass data for now). I was happy to stumble across this. Now… wondering if I could save an image file in there encoded in base64? Might have to give that a try, Wanted to see if I can pull in some images from an online source.