Thanks, that's really interesting! What is push data out?
I just committed those changes I mentioned above - it should be useful in a bunch of cases since it applies even to SPI/I2C/etc.
Basically this should mean that the setup is done only once - even in BytePort you had to grab the binary data out of a variable each call, but this should avoid that since it'll be stored on the stack - so I'm hopeful that with these changes we may end up with something even faster.
I don't have a P3 matrix here so this is what I did for the LPD6416 - hopefully the change is pretty straightforward.
// original
connect1 = function(pins) {
var s = shiftOut.bind(null, [pins.nG,pins.nR], { clk : pins.S, repeat : 4 });
var d = digitalWrite.bind(null, [pins.nEN,pins.L,pins.L,pins.D,pins.C,pins.B,pins.A,pins.nEN]);
var en = pins.nEN;
var g = Graphics.createArrayBuffer(64,16,2);
var u = g.buffer;
g.scan = function() {
en.reset();
for (var y=0;y<16;y++) {s(new Uint8Array(u,y*16,16));d(33|y<<1);}
en.set();
};
g.setBgColor(3);
g.setColor(0);
g.clear();
return g;
};
// fast
connect2 = function(pins) {
var s = shiftOut.bind(null, [pins.nG,pins.nR], { clk : pins.S, repeat : 4 });
var d = digitalWrite.bind(null, [pins.nEN,pins.L,pins.L,pins.D,pins.C,pins.B,pins.A,pins.nEN]);
var en = pins.nEN;
var g = Graphics.createArrayBuffer(64,16,2);
var u = g.buffer;
var arr = [];
g.prep = function() {
arr = [];
for (var y=0;y<16;y++) {
arr.push(new Uint8Array(u,y*16,16));
arr.push({callback:d.bind(null,33|y<<1)});
}
};
g.scan = function() {
en.reset();
s(arr);
en.set();
};
g.setBgColor(3);
g.setColor(0);
g.clear();
return g;
};
function time(fn) {
var g = fn({A:B15, B:B14, C:B13, D:B10,
nG:B1, L:A6, S:A5, nEN:A8, nR:A7});
if (g.prep) g.prep();
var t=getTime();
var n=100;
while (n--)g.scan();
print(getTime()-t);
}
// normal
time(connect1);
// save the loop and function calls - roughly twice as fast on STM32
time(connect2);
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.
Thanks, that's really interesting! What is
push data out
?I just committed those changes I mentioned above - it should be useful in a bunch of cases since it applies even to SPI/I2C/etc.
Basically this should mean that the setup is done only once - even in
BytePort
you had to grab the binary data out of a variable each call, but this should avoid that since it'll be stored on the stack - so I'm hopeful that with these changes we may end up with something even faster.I don't have a P3 matrix here so this is what I did for the LPD6416 - hopefully the change is pretty straightforward.