...but the code assumes that there is at least data available to fill three buffers (or at least the first two fully and the third partially)... because I do not see any checks before these three buffers are getting used. May be the implementation is tolerant to the case were not even the first buffer is full... ;) I'm also not sure if stopping at the moment when reading ahead the content for the next buffer switch is correct... the waveform may still have things to play off of the buffer to which it just has switched. @Gordon will for sure provide the needed insight here!
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.
...but the code assumes that there is at least data available to fill three buffers (or at least the first two fully and the third partially)... because I do not see any checks before these three buffers are getting used. May be the implementation is tolerant to the case were not even the first buffer is full... ;) I'm also not sure if stopping at the moment when reading ahead the content for the next buffer switch is correct... the waveform may still have things to play off of the buffer to which it just has switched. @Gordon will for sure provide the needed insight here!