What Espruino device are you running this on? I guess maybe converting the data to the newBinary string in one go is causing it to use a lot of memory, since each bit turns into 2 characters.
While what you're doing seems possible, I think using setInterval isn't really going to work for you, since the JS execution speed may not be fast enough, and any extra code that runs will delay execution.
However, you do have some other options:
You can pass an array into digitalPulse - it should work fine but creating the array will be a bit fiddly since you need to specify the time between pulses, not the actual pulse values
Use SPI with the right baud rate (but just the MOSI - output - pin). You just need to ensure that newBinary is a Uint8Array of binary data rather than a string (so effectively 4 bits of actual homebus data go to 1 byte of data in newBinary).
Hardware SPI probably won't run at exactly the right baud rate (depending on the board you're using) but software SPI should be fine
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.
What Espruino device are you running this on? I guess maybe converting the data to the
newBinary
string in one go is causing it to use a lot of memory, since each bit turns into 2 characters.While what you're doing seems possible, I think using setInterval isn't really going to work for you, since the JS execution speed may not be fast enough, and any extra code that runs will delay execution.
However, you do have some other options:
digitalPulse
- it should work fine but creating the array will be a bit fiddly since you need to specify the time between pulses, not the actual pulse valuesHardware SPI probably won't run at exactly the right baud rate (depending on the board you're using) but software SPI should be fine