Control any DMX512 compatible lighting system with node.js via FTDI USB-RS485 cable.
- node.js
- Сompatible USB-RS485 cable
- libftdi1 and libftdi-dev packages or libFTDI library
npm install git://github.com/unkernet/node-dmx.git
This sample code searches for the first available device and starts turn the light on and off infinitely
var DMX = require('./dmx_native.node');
var list = DMX.list();
console.log('Found ' + list.length + ' devices');
if (list.length > 0) {
try {
var dmx = DMX.DMX(0);
} catch (e) {
console.error(e.message);
process.exit();
}
dmx.setHz(20);
dmx.step(5);
var val = [255], odd=true;
setInterval(function(){
dmx.set(val);
val.unshift(odd =! odd ? 255 : 0);
if (val.length > 512) val.pop();
}, 3000);
}
- I have
ftdi_usb_open_dev failed
error
Try tosudo rmmod ftdi_sio
list ()
Return an array with all available devices, or empty array if no devices found.DMX (index)
Open device with specified index and return a DMX object. 0 is for the first.
start ()
Begin transmission of DMX packetsstop (wait)
Stop transmission of DMX packets. If wait is true, wait until the end of thread.step (step)
Set the maximum level change in one cycle. Default 255 means immediately. Useful for slow light transactions.setHz (Hz)
Set count of DMX packets transmitted per second. From 1 to 50, default 25. More than 38 may cause blinking due to transmission errors.set (value)
Set value of channels. If the number specified will set all 512 channels to same level. If array, level will be set for the firstvalue.length
channels.