node-serialosc
node-serialosc allows easy integration with monome grid and arc devices. You can install it via npm:
npm install serialosc
Simple Example
This example script will listen for devices and attach a key handler that sets the corresponding led:
var serialosc = ;serialoscstart;serialosc;
Configuration
You can pass configuration options to the start method:
serialoscstart host: 'localhost' // ip/hostname to listen on port: 4200 // port to listen on (default = random port number) serialoscHost: 'locahost' // ip/hostname where serialosc is running serialoscPort: 12002 // port where serialosc is running startDevices: true // auto-start devices;
If startDevices is set to false you will need to start the device manually and listen for the initialized event. This can be helpful if you want to run multiple applications but only initialize certain devices in each application. For example:
serialoscstart startDevices: false;serialosc;
Events
You can listen for device:add or device:remove events
serialosc; serialosc;
You can also listen by device id:
serialosc; serialosc;
Devices
Devices are passed through device:add events. You can also access an array of devices at serialosc.devices
// an example device id: 'm40h0800' type: 'monome 40h' host: 'localhost' port: 14123 deviceHost: 'localhost' devicePort: 11109 connected: true
Grid Devices
Use device.on('key', callback) to listen for key press events. Press events are objects in the form:
{x: ..., y: ..., s: ...}:
Example:
device;
You can set the LEDs of a grid device using the following methods:
device;// alternate set syntaxdevice;device;device;deviceall1;device;// alternate map syntaxdevice;
For varibright devices:
device;// alternate set syntaxdevice;device;device;device;device;
Arc Devices
Use device.on('key', callback) to listen for encoder press events. Press events are objects in the form:
{n: ..., s: ...}:
Example:
device;
Use device.on('delta', callback) to listen for encoder delta events. Delta events are objects in the form:
{n: ..., d: ...}:
Example:
device;
You can set the LEDs of an arc device using the following methods:
device;// alternate set syntaxdevice;device;deviceall0 15;device;