I'm trying to use Espruino as the controller to take LED matrix data from the Glediator over USB and output it onto an RGB LED matrix.
The Matrix is made up on 16x8 WS2812B pixels. I've attached the example code from Glediator for using an Arduino as the controller which I've tried ported to JS (see below).
I've tried using the example USART code from here: http://www.espruino.com/USART along with other code I found on the forum but so far nothing has worked. Is there something I'm missing in the code below? I'm unsure if data is being received but Espruino as I can't connect while data is being sent to check.
function onInit() {
SPI2.setup({baud:3200000, mosi:B15});
var m = Graphics.createArrayBuffer(16,8,24,{zigzag:true,color_order:'bgr'});
m.flip = function(){ SPI2.send4bit(m.buffer, 0b0001, 0b0011); }; // Not sure if I need this line?
USB.setup(115200);
portData();
}
function portData() {
USB.on('data', function (data) {
USB.print(data);
cmd+=data;
var idx = cmd.indexOf("\r");
while (idx>=0) {
var line = cmd.substr(0,idx);
cmd = cmd.substr(idx+1);
var s = "'"+line+"' = "+eval(line);
print(s);
USB.println(s);
idx = cmd.indexOf("\r");
SPI2.send4bit(cmd, 0b0001, 0b0011);
}
});
}
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.
I'm trying to use Espruino as the controller to take LED matrix data from the Glediator over USB and output it onto an RGB LED matrix.
The Matrix is made up on 16x8 WS2812B pixels. I've attached the example code from Glediator for using an Arduino as the controller which I've tried ported to JS (see below).
I've tried using the example USART code from here: http://www.espruino.com/USART along with other code I found on the forum but so far nothing has worked. Is there something I'm missing in the code below? I'm unsure if data is being received but Espruino as I can't connect while data is being sent to check.
1 Attachment