t=(this.cap>65536)?E.toString(3,add>>16&0xff,add>>8&0xff,add&0xff):E.toString(3,add>>8&0xff,add&0xff);
var ov=this.spi.send(t,this.cspin);
var o=new Uint8Array(ov.buffer,(this.cap>65536?4:3),bytes);
If you send a string to SPI.send then I'm pretty sure it'll return a string rather than an ArrayBuffer, which I guess is causing the issue. Looks like the following might fix it?
var t=(this.cap>65536)?E.toUint8Array(3,add>>16,add>>8,add):E.toUint8Array(3,add>>8,add);
var ov=this.spi.send(t,this.cspin);
var o=new Uint8Array(ov.buffer,(this.cap>65536?4:3),bytes);
toUint8Array and toString have an implicit &0xFF as they're converting to 8 bits, so you can also slim down the code a bit (done above) if you want to.
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.
Just to add:
If you send a string to
SPI.send
then I'm pretty sure it'll return a string rather than an ArrayBuffer, which I guess is causing the issue. Looks like the following might fix it?toUint8Array and toString have an implicit
&0xFF
as they're converting to 8 bits, so you can also slim down the code a bit (done above) if you want to.