|
|
|
@ -12,10 +12,10 @@ var BOB_tol_booth = null; |
|
|
|
var BOB_cfg_config = null; |
|
|
|
|
|
|
|
var BOB_var_boothInProgress = 0; |
|
|
|
var BOB_var_gamepad = require("gamepad"); |
|
|
|
//var BOB_var_gamepad = require("gamepad");
|
|
|
|
var BOB_var_ipAddress = '127.0.0.1'; |
|
|
|
|
|
|
|
var BOB_var_path = "/home/cocoon/workspace/bobinoscope"; |
|
|
|
var BOB_var_path = "/home/odroid/workspace/bobinoscope"; |
|
|
|
|
|
|
|
var BOB_var_killZone = { |
|
|
|
top : 2, |
|
|
|
@ -85,6 +85,28 @@ BOB_mod_router.get('/print/list/todo', function(req, res, next) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
BOB_mod_router.get('/fixdate', function (req, res, next) { |
|
|
|
res.render('fixdate', {serverIpAddress: BOB_var_ipAddress}); |
|
|
|
}) |
|
|
|
|
|
|
|
BOB_mod_router.get('/fixdate/:timestamp', function(req, res, next) { |
|
|
|
var spawn = require('child_process').spawn; |
|
|
|
|
|
|
|
var date = spawn('date', ['-s', '@'+(req.params.timestamp/1000)]); |
|
|
|
|
|
|
|
var error = ''; |
|
|
|
|
|
|
|
date.stdout.on('data', function(data) {console.log(data.toString())}); |
|
|
|
|
|
|
|
date.stderr.on('data', function(data) {error += data; console.log(data.toString())}); |
|
|
|
|
|
|
|
date.on('close', function(code) { |
|
|
|
res.json({error : code !== 0 ? error : ''}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function copyFile(source, target, cb) { |
|
|
|
var cbCalled = false; |
|
|
|
@ -111,23 +133,46 @@ function copyFile(source, target, cb) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var gpio = require("odroid-gpio"); |
|
|
|
var previous = 1; |
|
|
|
gpio.open(7, "input pullup", function(err) { // Open pin 16 for output
|
|
|
|
console.log(err) |
|
|
|
|
|
|
|
setInterval(function() { |
|
|
|
gpio.read(7, function(err, value) { |
|
|
|
if(err) console.log(err); |
|
|
|
// console.log(value); // The current state of the pini
|
|
|
|
if (value === 0 && value !== previous) { |
|
|
|
console.log('click') |
|
|
|
BOB_cfg_config.io.emit('boothClick', { |
|
|
|
id : 0, |
|
|
|
num : 0 |
|
|
|
}); |
|
|
|
} |
|
|
|
previous = value; |
|
|
|
}); |
|
|
|
}, 200) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize the library
|
|
|
|
BOB_var_gamepad.init() |
|
|
|
//BOB_var_gamepad.init()
|
|
|
|
// List the state of all currently attached devices
|
|
|
|
for (var i = 0, l = BOB_var_gamepad.numDevices(); i < l; i++) { |
|
|
|
console.log(i, BOB_var_gamepad.deviceAtIndex(i)); |
|
|
|
} |
|
|
|
//for (var i = 0, l = BOB_var_gamepad.numDevices(); i < l; i++) {
|
|
|
|
// console.log(i, BOB_var_gamepad.deviceAtIndex(i));
|
|
|
|
//}
|
|
|
|
// Create a game loop and poll for events
|
|
|
|
setInterval(BOB_var_gamepad.processEvents, 16); |
|
|
|
//setInterval(BOB_var_gamepad.processEvents, 16);
|
|
|
|
// Scan for new gamepads as a slower rate
|
|
|
|
setInterval(BOB_var_gamepad.detectDevices, 500); |
|
|
|
//setInterval(BOB_var_gamepad.detectDevices, 500);
|
|
|
|
// Listen for button down events on all gamepads
|
|
|
|
BOB_var_gamepad.on("down", function (pId, pNum) { |
|
|
|
BOB_cfg_config.io.emit('boothClick', { |
|
|
|
id : pId, |
|
|
|
num : pNum |
|
|
|
}); |
|
|
|
}) |
|
|
|
//BOB_var_gamepad.on("down", function (pId, pNum) {
|
|
|
|
// BOB_cfg_config.io.emit('boothClick', {
|
|
|
|
// id : pId,
|
|
|
|
// num : pNum
|
|
|
|
// });
|
|
|
|
//})
|
|
|
|
|
|
|
|
// Get local server ip address
|
|
|
|
var ifaces = BOB_mod_os.networkInterfaces(); |
|
|
|
|