Hi Gordon,
I understand the idea but can't get it to work. It is outputting mostly random colours and the idx.length looks too small. My guess is it's receiving the data but doesn't know where the frame begins or perhaps the frame break "\1" is being included in the output.
I've tweaked your code a bit to get it working but with the problems above.
PS. I've been running this code on both the Pico and orgional Espruino with the same results on both.
/**
Glediator settings
Driver: Glediator
Baud 115200
Colour order: GRB
Pixel order: HS_TL
*/
var fps = 0,
buf = new Uint8Array(15*15*3),
bufIdx = 0,
cmd = "";
function onInit() {
SPI1.setup({baud:3200000, mosi:A7});
Serial1.setup(115200, {tx:B6,rx:B7});
Serial1.on('data', function (data) {
buf.set(data, bufIdx);
bufIdx += data.length;
if (data.indexOf("\1") >= 0) {
var idx = bufIdx + data.indexOf("\1");
var line = new Uint8Array(buf.buffer, 0, idx);
console.log(idx);
SPI1.send4bit(line, 0b0001, 0b0011);
buf.set(new Uint8Array(buf.buffer, idx, bufIdx-idx), 0);
bufIdx -= idx;
fps++;
}
});
var fps = setInterval(function() {
console.log('fps: ' + fps);
fps = 0;
}, 1000);
}
onInit();
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.
Hi Gordon,
I understand the idea but can't get it to work. It is outputting mostly random colours and the idx.length looks too small. My guess is it's receiving the data but doesn't know where the frame begins or perhaps the frame break "\1" is being included in the output.
I've tweaked your code a bit to get it working but with the problems above.
PS. I've been running this code on both the Pico and orgional Espruino with the same results on both.
This outputs the following: