You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Wow, that stumped me - then I found:

    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.

    That might well sort out your ESP32 issues :)

About

Avatar for Gordon @Gordon started