Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update codebase to recover compatibility #33

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ module.exports = {
'showtec-multidim2': {
channels: ['1', '2', '3', '4']
},
'led-wall-tri-4c-1': {
channels: ['dimmer', 'red', 'green', 'blue'],
ranges: {
ctrl: {
type: 'option',
'options': [
{'value': 0, 'label': 'Dimmer'},
{'value': 0, 'label': 'Red'},
{'value': 0, 'label': 'Green'},
{'value': 0, 'label': 'Blue'},
]
},
'dimmer': {
'type': 'slider',
'min': 0,
'max': 255
}
}
},
'eurolite-led-bar': {
channels: ['ctrl', 'dimmer', 'strobe', 'red0', 'green0', 'blue0', 'red1', 'green1', 'blue1', 'red2', 'green2', 'blue2'],
ranges: {
Expand Down
21 changes: 12 additions & 9 deletions dmx-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var express = require('express')
var socketio = require('socket.io')
var program = require('commander')
var DMX = require('./dmx')
var pliabAnim = require('./pliabAnim')
var A = DMX.Animation

program
Expand Down Expand Up @@ -48,14 +49,9 @@ function DMXWeb() {
}
}
})
io.set('log level', 1)

app.configure(function() {
app.use(connect.json())
})

app.get('/', function(req, res) {
res.sendfile(__dirname + '/index.html')
res.sendFile(__dirname + '/index.html')
})

app.get('/config', function(req, res) {
Expand Down Expand Up @@ -93,10 +89,17 @@ function DMXWeb() {
// preserve old states
var old = dmx.universeToObject(req.params.universe)

var animation = new A()
for(var step in req.body) {
var animation = new A()
for(var step in req.body) {
let stepTo = req.body[step].to;

if (stepTo.hasOwnProperty('color') || stepTo.hasOwnProperty('opacity')) {
stepTo = pliabAnim.convertToDMX(stepTo);
}

console.log('stepTo', stepTo);
animation.add(
req.body[step].to,
stepTo,
req.body[step].duration || 0,
req.body[step].options || {}
)
Expand Down
28 changes: 28 additions & 0 deletions dmx-web.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"server": {
"listen_port": 8080,
"listen_host": "::"
},
"presets": [
{
"label": "White",
"values": {
"office": { "1": 16, "2": 255, "3": 0, "4": 255, "5": 255, "6": 255, "16": 16, "17": 255, "18": 0, "19": 255, "20": 255, "21": 255 }
}
}
],
"universes": {
"office": {
"output": {
"driver": "enttec-usb-dmx-pro",
"device": "/dev/cu.usbserial-EN216442"
},
"devices": [
{
"type": "led-wall-tri-4c-1",
"address": 0
}
]
}
}
}
4 changes: 2 additions & 2 deletions drivers/dmx4all.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function DMX4ALL(device_id, options) {
this.universe.fill(0)

this.dev = new SerialPort(device_id, {
'baudrate': 38400,
'baudRate': 38400,
'databits': 8,
'stopbits': 1,
'parity': 'none'
Expand All @@ -26,7 +26,7 @@ function DMX4ALL(device_id, options) {
}

DMX4ALL.prototype.send_universe = function() {
if(!this.dev.isOpen()) {
if(!this.dev.writable) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/dmxking-ultra-dmx-pro.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function DMXKingUltraDMXPro(device_id, options) {
}

this.dev = new SerialPort(device_id, {
'baudrate': 250000,
'baudRate': 250000,
'databits': 8,
'stopbits': 2,
'parity': 'none'
Expand All @@ -37,7 +37,7 @@ function DMXKingUltraDMXPro(device_id, options) {
}

DMXKingUltraDMXPro.prototype.send_universe = function() {
if(!this.dev.isOpen()) {
if(!this.dev.writable) {
return
}
var hdr = Buffer([
Expand Down
4 changes: 2 additions & 2 deletions drivers/enttec-open-usb-dmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function EnttecOpenUsbDMX(device_id, options) {
self.interval = 46

this.dev = new SerialPort(device_id, {
'baudrate': 250000,
'baudRate': 250000,
'databits': 8,
'stopbits': 2,
'parity': 'none'
Expand All @@ -27,7 +27,7 @@ function EnttecOpenUsbDMX(device_id, options) {

EnttecOpenUsbDMX.prototype.send_universe = function() {
var self = this
if(!this.dev.isOpen()) {
if(!this.dev.writable) {
return
}

Expand Down
121 changes: 61 additions & 60 deletions drivers/enttec-usb-dmx-pro.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,76 @@
"use strict"
"use strict";

var SerialPort = require("serialport")
const SerialPort = require("serialport");

var ENTTEC_PRO_DMX_STARTCODE = 0x00
, ENTTEC_PRO_START_OF_MSG = 0x7e
, ENTTEC_PRO_END_OF_MSG = 0xe7
, ENTTEC_PRO_SEND_DMX_RQ = 0x06
, ENTTEC_PRO_RECV_DMX_PKT = 0x05
;
const ENTTEC_PRO_DMX_STARTCODE = 0x00
, ENTTEC_PRO_START_OF_MSG = 0x7e
, ENTTEC_PRO_END_OF_MSG = 0xe7
, ENTTEC_PRO_SEND_DMX_RQ = 0x06
, ENTTEC_PRO_RECV_DMX_PKT = 0x05
;

function EnttecUSBDMXPRO(device_id, options) {
var self = this
options = options || {}
this.universe = new Buffer(513)
this.universe.fill(0)

this.dev = new SerialPort(device_id, {
'baudrate': 250000,
'databits': 8,
'stopbits': 2,
'parity': 'none'
}, function(err) {
if(!err) {
self.send_universe()
}
})
}

EnttecUSBDMXPRO.prototype.send_universe = function() {
if(!this.dev.isOpen()) {
return
const EnttecUSBDMXPRO = class EnttecUSBDMXPRO {
constructor(device_id, options) {
options = options || {};
this.universe = new Buffer(512);
this.universe.fill(0);

this.dev = new SerialPort(device_id, {
'baudRate': 250000,
'databits': 8,
'stopbits': 2,
'parity': 'none'
}, (err) => {
if(!err) {
this.send_universe();
}
})
}
var hdr = Buffer([
ENTTEC_PRO_START_OF_MSG,
ENTTEC_PRO_SEND_DMX_RQ,
(this.universe.length) & 0xff,
((this.universe.length) >> 8) & 0xff,
ENTTEC_PRO_DMX_STARTCODE
])

var msg = Buffer.concat([
hdr,
this.universe.slice(1),
Buffer([ENTTEC_PRO_END_OF_MSG])
])
this.dev.write(msg)
}
send_universe () {
if(!this.dev.writable) {
return;
}
const hdr = Buffer([
ENTTEC_PRO_START_OF_MSG,
ENTTEC_PRO_SEND_DMX_RQ,
(this.universe.length + 1) & 0xff,
((this.universe.length + 1) >> 8) & 0xff,
ENTTEC_PRO_DMX_STARTCODE
]);

const msg = Buffer.concat([
hdr,
this.universe,
Buffer([ENTTEC_PRO_END_OF_MSG])
]);
this.dev.write(msg);
}

EnttecUSBDMXPRO.prototype.start = function() {}
EnttecUSBDMXPRO.prototype.stop = function() {}
start() {}
stop() {}

EnttecUSBDMXPRO.prototype.close = function(cb) {
this.dev.close(cb)
}
close(cb) {
this.dev.close(cb);
}

EnttecUSBDMXPRO.prototype.update = function(u) {
for(var c in u) {
this.universe[c] = u[c]
update(u) {
for(let c in u) {
this.universe[c] = u[c];
}
this.send_universe();
}
this.send_universe()
}

EnttecUSBDMXPRO.prototype.updateAll = function(v){
for(var i = 1; i <= 512; i++) {
this.universe[i] = v
updateAll(v) {
for(let i = 0; i < 512; i++) {
this.universe[i] = v;
}
this.send_universe();
}
this.send_universe()
}

EnttecUSBDMXPRO.prototype.get = function(c) {
return this.universe[c]
get(c) {
return this.universe[c];
}
}

module.exports = EnttecUSBDMXPRO
24 changes: 13 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
function get_html_id(universe, channel) {
return 'channel_' + universe + '_' + channel;
}

var socket = io.connect();
var socket = io();
socket.on('init', function (msg) {
$('#presets').empty();
$('#sliders').empty();
Expand All @@ -73,7 +72,6 @@
socket.emit('update', universe, values[universe]);
}
};}(setup.presets[preset].values));
console.log(html);
}

/* blackout button */
Expand All @@ -95,16 +93,20 @@
var html = "<div><h1>" + universe + "</h1>";
for(var device in setup.universes[universe].devices) {
var dev = setup.universes[universe].devices[device];
html += '<div class="device">'
for(var channel in devices[dev.type].channels) {
var channel_id = dev.address + Number(channel)
var html_id = get_html_id(universe, channel_id);
html += '<div class="channel">'
html += '<label for="' + html_id + '">' + devices[dev.type].channels[channel] + '</label>';
html += '<input id="' + html_id + '" type="range" min="0" value="0" max="255" orient="vertical">'
if (devices[dev.type]) {
html += '<div class="device">'
for(var channel in devices[dev.type].channels) {
var channel_id = dev.address + Number(channel)
var html_id = get_html_id(universe, channel_id);
html += '<div class="channel">'
html += '<label for="' + html_id + '">' + devices[dev.type].channels[channel] + '</label>';
html += '<input id="' + html_id + '" type="range" min="0" value="0" max="255" orient="vertical">'
html += '</div>'
}
html += '</div>'
} else {
console.log("[WARNING] Device " + dev.type + " is unknown and cannot be displayed in sliders overview!")
}
html += '</div>'
}
html += "</div>";
$(html).hide().appendTo('#sliders').fadeIn();
Expand Down
Loading