hmm, there must be something different in our testing.
To compare Original Espruino Board with ESP32 I wrote some Q&U functions (quick and ugly)
As a first result I couldn't find any way to come down to 20ms, as you mentioned.
Strange results, in my eyes, are:
setting a pin is 3 times slower on ESP32
to figure out how much time goes to ESP-IDF, a simple test function is added to Source, which calls jshPinSetValue with true and with false. This takes a few ms only.
array copy from a big array already takes much more than 20 ms
LedShiftout which is similiar to the command in your module takes even more time
if setting a pin only takes some microsecs, why does setting with pin.set() take close to a millisec
var pin;
switch(process.env.BOARD){
case "ESPRUINOBOARD": pin = B5; break;
case "ESP32": pin = D5; break;
}
function test(fnc){
var t = new Date();
eval(fnc);
console.log(fnc.substr(3), ":" ,parseInt(new Date() -t));
}
function tstLoop(cnt){
for(var i = 0; i < cnt; i++){}
}
function tstArr(cnt){
var o;for(var i = 0; i < cnt; i++){o = new Uint8Array(1024);}
}
function tstPin(cnt){
for(var i = 0; i < cnt; i++){pin.set();}
}
function tstArrCopy(cnt){
var c,o = new Uint8Array(1024);
for(var i = 0; i < cnt; i += 4){
c = new Uint8Array(o,i,64);
}
}
function tstDigitalWrite(cnt){
var dfnc = digitalWrite.bind(null,[pin,pin,pin,pin,pin,pin,pin]);
for(i = 0; i < cnt; i++){
dfnc(33);
}
}
function tstShiftOut(cnt){
var arr = new Uint8Array(64);
var sfnc = shiftOut.bind(null,[pin,pin,pin,pin,pin,pin],{clk:pin});
for(var i = 0; i < cnt; i++){
sfnc(arr);
}
}
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 tstjshPinSetValue(cnt){
ESP32.test(pin,cnt);
}
test("tstLoop(1000)");
test("tstArr(100)");
test("tstPin(1000)");
test("tstArrCopy(16)");
test("tstShiftOut(16)");
test("tstLedShiftOut(16)");
test("tstDigitalWrite(16)");
switch(process.env.BOARD){
case "ESP32": test("tstjshPinSetValue(6144)"); break;
}
Result in Millisconds of running test on both boards
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.
hmm, there must be something different in our testing.
To compare Original Espruino Board with ESP32 I wrote some Q&U functions (quick and ugly)
As a first result I couldn't find any way to come down to 20ms, as you mentioned.
Strange results, in my eyes, are:
if setting a pin only takes some microsecs, why does setting with pin.set() take close to a millisec
Result in Millisconds of running test on both boards