i packed it into some handy functions extending your E instance:
// grant flat arraybuffer http://forum.espruino.com/conversations/316409/#comment14077573
if (E.newArrayBuffer===undefined) E.newArrayBuffer= function(bytes){
const mem= E.toString({data:0,count:bytes}); // undefined -> failed to alloc the *flat* string
if (!mem) throw Error('alloc flat for '+bytes+' bytes FAILED!');
return E.toArrayBuffer(mem);
};
if (E.newUint8Array===undefined) E.newUint8Array= function(cnt){
return new Uint8Array( E.newArrayBuffer(cnt));
};
if (E.newUint16Array===undefined) E.newUint16Array= function(cnt){
return new Uint16Array( E.newArrayBuffer(cnt*2));
};
if (E.newUint32Array===undefined) E.newUint32Array= function(cnt){
return new Uint32Array( E.newArrayBuffer(cnt*4));
};
at the moment, my DMA extension for SPI supports TX only - but gives a really fine performance improvement when running at 12.5 MBaud.
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.
many thx - nice hack to get a flat Uint8Array ;)
i packed it into some handy functions extending your E instance:
at the moment, my DMA extension for SPI supports TX only - but gives a really fine performance improvement when running at 12.5 MBaud.