HISTORY object contains 8 typed 48 element arrays (representing data every 30 minutes), 4 Float32Arrays and 4 Uint16Arrays. The time data is not retained - I push onto one end and drop the oldest value every time I update it (by looping over the arrays since I can't do push() with a typed array). This works.
The problem is that I need to stringify the whole thing and send it as JSON to the webpage that will display it as a nice neat graph. However, I get out of memory when I do this - in the above, I've commented out all except RH, Temp, and Clear - which works, but then I don't get to have all the data I want.
I've tried breaking it all up into separate documents, but this doesn't work either - still runs out of memory, I think because it's not waiting until everything gets sent before stuffing more into the bufer.
It looks like the drain() method is made just for this kind of thing - but I don't know how to use it and there are no examples :-(
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.
I don't understand what you're suggesting?
HISTORY object contains 8 typed 48 element arrays (representing data every 30 minutes), 4 Float32Arrays and 4 Uint16Arrays. The time data is not retained - I push onto one end and drop the oldest value every time I update it (by looping over the arrays since I can't do push() with a typed array). This works.
The problem is that I need to stringify the whole thing and send it as JSON to the webpage that will display it as a nice neat graph. However, I get out of memory when I do this - in the above, I've commented out all except RH, Temp, and Clear - which works, but then I don't get to have all the data I want.
I've tried breaking it all up into separate documents, but this doesn't work either - still runs out of memory, I think because it's not waiting until everything gets sent before stuffing more into the bufer.
It looks like the drain() method is made just for this kind of thing - but I don't know how to use it and there are no examples :-(