Skip to content

Commit

Permalink
Adds pages and serial communication
Browse files Browse the repository at this point in the history
  • Loading branch information
drGrove committed Apr 14, 2014
1 parent 4a98203 commit a1e9020
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var express = require('express'),
controller = require('./libs/controller')

var app = express();
app.get('/rainbow1', controller.rainbow1())
app.get('/rainbow2', controller.rainbow2())
app.get('/eq1', controller.eq1())
app.get('/eq2', controller.eq2())
app.get('/*', function(req, res){
res.send('This page is not active');
})
26 changes: 26 additions & 0 deletions libs/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var serial = require('serialport').SerialPort,
sp = new serial("/dev/USB0",
{ baudrate: 57600
}
)

var controller = {};

controller.rainbow1 = function(req, res){
sp.write('rainbow1/n');
req.send("success")
}
controller.rainbow2 = function(req, res){
sp.write('rainbow2/n');
req.send("success")
}
controller.eq1 = function(req, res){
sp.write('eq1/n');
req.send("success")
}
controller.eq2 = function(req, res){
sp.write('eq2/n');
req.send("success")
}

module.exports = controller;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
},
"homepage": "https://github.com/HakrLabs/NeoControl-Server",
"dependencies": {
"serialport": "~1.3.1"
"serialport": "^1.3.1"
}
}

0 comments on commit a1e9020

Please sign in to comment.