@phortran and I have taken a reasonable fast pass at overhauling the monome-grid
node.js library. (This is exactly the sort of thing I do during the hoildays).
Obvious changes: it works again. (It was not working for me when I first downloaded it). We’ve updated the syntax and style to use ‘modern’ Javascript (eg ES2016), in particular initialising the grid with a Promise, and everything works out of the box with Node 8.9.x.
To go along with that, I’ve rewritten the node.js grid studies to reflect the syntax changes - the text documentation and all sample files are now updated to work with the new library. I can confirm it’s definitely very pleasant and quick to work with.
Finally, as an example, here’s what simple code to receive keypresses and toggle the associated LED on and off with each press looks like:
const monomeGrid = require('monome-grid');
async function run() {
let grid = await monomeGrid(); // optionally pass in grid identifier
// initialize 2-dimensional led array
let led = [];
for (let y=0;y<8;y++) {
led[y] = [];
for (let x=0;x<16;x++)
led[y][x] = 0;
}
let dirty = true;
// refresh leds with a pattern
let refresh = function() {
if(dirty) {
grid.refresh(led);
dirty = false;
}
}
// call refresh() function 60 times per second
setInterval(refresh, 1000 / 60);
// set up key handler
grid.key((x, y, s) => {
if(s == 1) led[y][x] ^= 15;
dirty = true;
});
}
run();