I guess I could add a read function that would pump out however many bytes were needed - as you say, 0xFF might be best. It's not a massive problem to create an array of bytes to stick into send though.
You could always write something like:
if (!SPI.prototype.read) SPI.prototype.read = function(n,p) { var a = new Uint8Array(n); a.fill(0xFF); return this.send(a,p); }
and then if a read function does get added, you code should swap over gracefully.
In terms of expecting data - I think you just have to 'know' - sometimes you can ask the device, but sometimes you'll just have to check the datasheet and figure it out.
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 guess I could add a read function that would pump out however many bytes were needed - as you say, 0xFF might be best. It's not a massive problem to create an array of bytes to stick into
send
though.You could always write something like:
and then if a
read
function does get added, you code should swap over gracefully.In terms of expecting data - I think you just have to 'know' - sometimes you can ask the device, but sometimes you'll just have to check the datasheet and figure it out.