Skip to content

Instantly share code, notes, and snippets.

@seriousManual
Created July 1, 2017 10:58
Show Gist options
  • Save seriousManual/ce2b332986d4d04ad832cbb6c56e8522 to your computer and use it in GitHub Desktop.
Save seriousManual/ce2b332986d4d04ad832cbb6c56e8522 to your computer and use it in GitHub Desktop.
const lunchpad = require('lunchpad')
const initializeLP = lunchpad.initialize
const Color = lunchpad.Color
const fivetwelve = require('fivetwelve/es5')
const EnttecUsbProMk2Driver = require('fivetwelve-driver-usbpro/es5')
const SerialPort = require('serialport')
let fivetwelveInit = fivetwelve.default
let DmxDevice = fivetwelve.DmxDevice
let usbSerialPort = new SerialPort('COM5')
let output = fivetwelveInit(new EnttecUsbProMk2Driver(usbSerialPort))
output.start(30)
let device = new DmxDevice(1, {
brightness: new fivetwelve.param.RangeParam(1),
color: new fivetwelve.param.RgbParam([2,3,4])
})
device.setOutput(output)
device.brightness = 1
device.color = '#000'
initializeLP().then(launchpad => {
launchpad
.clearSquares()
.setSquare(0, 0, Color.RED)
.setSquare(1, 0, Color.GREEN)
.setSquare(2, 0, Color.AMBER)
.on('input', (x, y) => {
if (x == 0 && y == 0) {
device.color = '#f00'
} else if (x == 1 && y == 0) {
device.color = '#0f0'
} else if (x == 2 && y == 0) {
device.color = '#ffd800'
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment