Well, using just Storage.write will result in the whole file re-written each time, which is obviously not good. Storage.open(file,"a") creates a slightly different file type which allows easy appends, but dropping the first few lines of the file and rewriting will still be bad.
What I'd suggest is to have one StorageFile (with Storage.open(file,"a")) for each day of the week, and then at midnight when you swap over you do Storage.open(file,"r").erase() to erase the previous day (7 days ago) before starting afresh.
That way you're actually being super kind to the flash, and it should be reasonably easy to implement?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Well, using just
Storage.write
will result in the whole file re-written each time, which is obviously not good.Storage.open(file,"a")
creates a slightly different file type which allows easy appends, but dropping the first few lines of the file and rewriting will still be bad.What I'd suggest is to have one StorageFile (with
Storage.open(file,"a")
) for each day of the week, and then at midnight when you swap over you doStorage.open(file,"r").erase()
to erase the previous day (7 days ago) before starting afresh.That way you're actually being super kind to the flash, and it should be reasonably easy to implement?