As others have said, the storage library with large files is best - it calls into the same flash write routines under the hood but it just ensures you're writing to the correct place. There are some examples at https://www.espruino.com/Data+Collection#flash-memory which might help you for reading/writing raw data
Make a big (100k?) RAM buffer with a Uint8Array and then access it with a DataView
When that gets full, write it with Storage.write to a new file
Then you don't need to bother with appending or anything fancy. You've got 8MB of flash, so with 100k buffers it's only 80 files which isn't really a huge problem (each file has a 32b header so it's not like you're losing much space).
Writing 100k to a file will take about 0.3s, but that might well not be a big problem for you? Even if you used slightly smaller files it may still be easier and safer than managing writing individual bits to a big file.
The benefit is that when you're downloading from the watch you've also got a nice easy way to handle transfers - just search for and download any data files you see, then delete them afterwards.
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.
As others have said, the storage library with large files is best - it calls into the same
flash
write routines under the hood but it just ensures you're writing to the correct place. There are some examples at https://www.espruino.com/Data+Collection#flash-memory which might help you for reading/writing raw dataThis might help too - showing how to write data and also read it back automatically when the Bangle goes in range: https://www.espruino.com/Auto+Data+Download
Personally, on Bangle.js 2 you've got a decent amount of RAM. If you're not doing anything else with the watch and are just using it for logging:
Storage.write
to a new fileThen you don't need to bother with appending or anything fancy. You've got 8MB of flash, so with 100k buffers it's only 80 files which isn't really a huge problem (each file has a 32b header so it's not like you're losing much space).
Writing 100k to a file will take about 0.3s, but that might well not be a big problem for you? Even if you used slightly smaller files it may still be easier and safer than managing writing individual bits to a big file.
The benefit is that when you're downloading from the watch you've also got a nice easy way to handle transfers - just search for and download any data files you see, then delete them afterwards.