which will transmit 4 bytes that can be reconstructed into a 32 bit int. Normally you'd have ... &255 there but it's sort of implicit since only the bottom 8 bits of each element is used anyway.
If you want something that looks a bit nicer you can use DataView instead of all the bit shifting too.
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.
the code you have should work, but you're supplying an array with one element, so it'll only be sending one byte (0..255) worth of data.
You can do:
which will transmit 4 bytes that can be reconstructed into a 32 bit int. Normally you'd have
... &255
there but it's sort of implicit since only the bottom 8 bits of each element is used anyway.If you want something that looks a bit nicer you can use DataView instead of all the bit shifting too.