matelight client for node.js using CRAP, the "Custom advanced video stReAming Protocol".
Install with:
npm install matelight
Examples are in the matelight playground
If you don't have a matelight, you can also use the emulator.
var matelight = require('matelight');
var client = matelight.connect();
client.startLoop(function(){
client.setLight(2, 2, 200, 0, 200);
});
Create a new matelight connection. The host
and port
default to matelight.cbrp3.c-base.org:1337
.
This will be fine if you are at the c-base and your computer is connected to the crew network.
Cleans the matelight screen by setting all lights to off.
Sets the light at positon x, y to color RGB(r, g, b)
CAUTION: the x and y values start at 1 as this seemed more intuitiv when pointing at the matelight.
Here is a sample that turns the most upper left light to red and the most lower right light to blue:
client.setLight(1, 1, 255, 0, 0);
client.setLight(40, 16, 0, 0, 255);
Starts a loop which will clean the sceen, run the callback and then send all the lights which are set in the callback to the matelight screeen. If no intervall is given, it will default to 300 ms which seems to be a compromise between high framerates and dropped packages.
This example will send a red to the most upper left light every 100 ms:
var client = matelight.connect();
client.startLoop(function(){
client.setLight(1, 1, 255, 0, 0);
}, 100);
Stops the loop. Nothing will be send to the matelight anymore.
CAUTION: Even if the loop is stopped, some UDP packages might still arrive at the matelight.
Some things that are exposed through the module. Only mess with this if you know what you are doing.
The ammount of rows of the matelight
The ammount of columns of the matelight
The underlying udp client which is used to send the image buffers