Sequencer and firmware work together

This commit is contained in:
Matt 2016-04-18 21:52:38 -04:00
parent f4b75d7398
commit 2887182282
4 changed files with 31 additions and 6 deletions

View File

@ -2771,6 +2771,7 @@ cmd.cam_forward = function (rgb, callback) {
var res = function (ms) {
gui.updateState();
setTimeout(function () {
light.display([0,0,0]);
light.set([0, 0, 0], function () {
if (callback) { callback(ms); }
});
@ -2779,6 +2780,7 @@ cmd.cam_forward = function (rgb, callback) {
if (!mcopy.state.camera.direction) {
cam.set(true, function () {
setTimeout( function () {
light.display(rgb);
light.set(rgb, function () {
setTimeout( function () {
cam.move(res);
@ -2787,6 +2789,7 @@ cmd.cam_forward = function (rgb, callback) {
}, mcopy.cfg.arduino.serialDelay);
});
} else {
light.display(rgb);
light.set(rgb, function () {
setTimeout(function () {
cam.move(res);
@ -2803,6 +2806,7 @@ cmd.cam_backward = function (rgb, callback) {
'use strict';
var res = function (ms) {
gui.updateState();
light.display([0,0,0]);
light.set([0, 0, 0], function () {
if (callback) { callback(ms); }
});
@ -2810,6 +2814,7 @@ cmd.cam_backward = function (rgb, callback) {
if (mcopy.state.camera.direction) {
cam.set(false, function () {
setTimeout(function () {
light.display(rgb);
light.set(rgb, function () {
cam.move(res);
});
@ -2817,6 +2822,7 @@ cmd.cam_backward = function (rgb, callback) {
});
} else {
setTimeout(function () {
light.display(rgb);
light.set(rgb, function () {
cam.move(res);
});

View File

@ -28,7 +28,7 @@ mcopy.arduino = {
};
mcopy.arduino.enumerate = function (callback) {
'use strict';
console.log('Searching for devices...');
//console.log('Searching for devices...');
var cmd = 'ls /dev/tty.*';
exec(cmd, function (e, std) {
var devices = std.split('\n'),
@ -85,7 +85,7 @@ mcopy.arduino.end = function (data) {
ms = end - mcopy.arduino.timer;
if (mcopy.arduino.queue[data] !== undefined) {
mcopy.arduino.lock = false;
console.log('Command ' + data + ' took ' + ms + 'ms');
//console.log('Command ' + data + ' took ' + ms + 'ms');
mcopy.arduino.queue[data](ms); //execute callback
delete mcopy.arduino.queue[data];
} else {
@ -104,7 +104,7 @@ mcopy.arduino.connect = function (serial, device, confirm, callback) {
if (callback) { callback(error); }
return console.log('failed to open: '+ error);
} else {
console.log('Opened connection with ' + mcopy.arduino.path[serial]);
//console.log('Opened connection with ' + mcopy.arduino.path[serial]);
if (!confirm) {
mcopy.arduino.serial[serial].on('data', function (data) {
data = data.replace('\r', '');
@ -176,7 +176,7 @@ mcopy.arduino.close = function (callback) {
};
mcopy.arduino.fakeConnect = function (serial, callback) {
console.log('Connecting to fake arduino...');
//console.log('Connecting to fake arduino...');
mcopy.arduino.serial[serial] = {
write : function (cmd, res) {
var t = {
@ -196,7 +196,7 @@ mcopy.arduino.fakeConnect = function (serial, callback) {
},
fake : true
};
console.log('Connected to fake arduino! Not real! Doesn\'t exist!');
//console.log('Connected to fake arduino! Not real! Doesn\'t exist!');
if (callback) callback();
};

View File

@ -118,10 +118,23 @@ var distinguishDevices = function (devices) {
});
}
}
if (devices.length > 1) {
distinguishDevice(devices[1], distinguishTwo);
}
});
},
distinguishTwo = function (err, type) {
arduino.close(function () {
if (type === 'projector') {
arduino.connect('projector', devices[1], false, function () {
log.info('Connected to ' + devices[1] + ' as PROJECTOR', 'SERIAL', true, true);
});
} else if (type === 'camera') {
arduino.connect('camera', devices[1], false, function () {
log.info('Connected to ' + devices[1] + ' as CAMERA', 'SERIAL', true, true);
});
}
});
};
distinguishDevice(devices[0], distinguishOne);
};

View File

@ -315,6 +315,7 @@ cmd.cam_forward = function (rgb, callback) {
var res = function (ms) {
gui.updateState();
setTimeout(function () {
light.display([0,0,0]);
light.set([0, 0, 0], function () {
if (callback) { callback(ms); }
});
@ -323,6 +324,7 @@ cmd.cam_forward = function (rgb, callback) {
if (!mcopy.state.camera.direction) {
cam.set(true, function () {
setTimeout( function () {
light.display(rgb);
light.set(rgb, function () {
setTimeout( function () {
cam.move(res);
@ -331,6 +333,7 @@ cmd.cam_forward = function (rgb, callback) {
}, mcopy.cfg.arduino.serialDelay);
});
} else {
light.display(rgb);
light.set(rgb, function () {
setTimeout(function () {
cam.move(res);
@ -347,6 +350,7 @@ cmd.cam_backward = function (rgb, callback) {
'use strict';
var res = function (ms) {
gui.updateState();
light.display([0,0,0]);
light.set([0, 0, 0], function () {
if (callback) { callback(ms); }
});
@ -354,6 +358,7 @@ cmd.cam_backward = function (rgb, callback) {
if (mcopy.state.camera.direction) {
cam.set(false, function () {
setTimeout(function () {
light.display(rgb);
light.set(rgb, function () {
cam.move(res);
});
@ -361,6 +366,7 @@ cmd.cam_backward = function (rgb, callback) {
});
} else {
setTimeout(function () {
light.display(rgb);
light.set(rgb, function () {
cam.move(res);
});