0.0.2 • Published 10 years ago
node-dimensions v0.0.2
node-dimensions
Lego Dimensions Toy Pad library for NodeJS.
Installation
npm install node-dimensions --saveUsage
Load the module
var dimensions = require('node-dimensions');Connect to a device
Construct a new device and connect to it:
device = new dimensions.Device();
device.connect();Optionally, listen for the device to connect:
device.on('connected', function() {
});Listen for minifig scans
Listening for minifigs scans can be done by registering an handler:
device.on('minifig-scan', function(event) {
});Notes:
- The identity of a minifig can be checked via the
minifigproperty. For example:event.minifig == dimensions.Minifig.BATMAN. - Events are received when a minifig is added or removed from a panel. The
actionevent property specifies eitherdimensions.Minifig.ADDordimensions.Minifig.REMOVE - The
panelproperty specifies on which panel the scan occurred. This can be one ofdimensions.Panel.LEFT,dimensions.Panel.RIGHT, ordimensions.Panel.CENTER.
Update panel LEDs
Panel LEDs can be updated using the following:
device.updatePanel(panel, color, speed);Arguments:
panel- The panel to be updated, can be one ofdimensions.Panel.LEFT,dimensions.Panel.RIGHT,dimensions.Panel.CENTER,dimensions.Panel.ALL.color- The RGB color of the panel. For example: red would be0xFF0000while0x000000would turn off the LEDs.speed- An optional parameter specifying the speed with which to update the panel LEDs.0.0is the slowest update speed available, while1.0is the fastest.