function tstLedShiftOut(cnt){
var arr = new Uint8Array(1024);
var sfnc = shiftOut.bind(null,[pin,pin,pin,pin,pin,pin],{clk:pin});
for(var i = 0; i < cnt; i++){
sfnc(new Uint8Array(arr,i*64,64));
}
}
function tstLedShiftOut2(cnt){
var arr = new Uint8Array(1024).buffer;
var sfnc = shiftOut.bind(null,[pin,pin,pin,pin,pin,pin],{clk:pin});
for(var i = 0; i < cnt; i++){
sfnc(new Uint8Array(arr,i*64,64));
}
}
test("tstLedShiftOut(16)");
test("tstLedShiftOut2(16)");
> LedShiftOut(16) : 473
> LedShiftOut2(16) : 13
The Array copy does take a bunch of time - but if you use .buffer then it's not doing a copy - it just creates a 'view' and no data gets allocated or shovelled around.
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.
Wow, that stumped me - then I found:
The Array copy does take a bunch of time - but if you use
.buffer
then it's not doing a copy - it just creates a 'view' and no data gets allocated or shovelled around.That might well sort out your ESP32 issues :)