WIP wednesday

This commit is contained in:
mmcwilliams 2019-03-20 18:37:00 -04:00
parent 7f0ab0fee3
commit f2c2d6ce43
6 changed files with 155 additions and 26 deletions

View File

@ -283,17 +283,17 @@ class Arduino {
type = 'projector_second'; type = 'projector_second';
} }
else if (data === cfg.ardino.cmd.proj_dual_identifier) { else if (data === cfg.ardino.cmd.proj_dual_identifier) {
type = 'projectors'; type = 'projector,projector_second';
} }
else if (data === cfg.ardino.cmd.cam_second_identifier) { else if (data === cfg.ardino.cmd.cam_second_identifier) {
type = 'camera_second'; type = 'camera_second';
} }
else if (data === cfg.ardino.cmd.cam_dual_identifier) { else if (data === cfg.ardino.cmd.cam_dual_identifier) {
type = 'cameras'; type = 'camera,camera_second';
} }
//camera,projectors //camera,projector,projector_second
//cameras,projector //camera,camera_second,projector
//cameras,projectors //camera,camera_second,projector,projector_second
return resolve(type); return resolve(type);
}; };
await delay(cfg.arduino.serialDelay); await delay(cfg.arduino.serialDelay);

View File

@ -202,16 +202,39 @@ cmd.black_backward = function (callback) {
cam_forward_cam2_backward : 'CFCB', cam_forward_cam2_backward : 'CFCB',
cam_backward_cam2_forward : 'CBCF', cam_backward_cam2_forward : 'CBCF',
proj2_forward : 'P2F',
proj2_backward : 'P2B',
projs_forward : 'PPF',
projs_backward : 'PPB',
proj_forward_proj2_backward : 'PFPB',
proj_backward_proj2_forward : 'PBPF'
*/ */
/**
* Move the secondary projector forward one frame
*
* @param {function} callback Function to call after action
**/
cmd.proj2_forward = function (callback) {
'use strict';
var res = function (ms) {
$('#cmd_proj2_forward').removeClass('active');
gui.updateState();
if (callback) { callback(ms); }
};
$('#cmd_proj2_forward').addClass('active');
if (!mcopy.state.projector2.direction) {
proj.set2(true, function (ms) {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}
};
cmd.proj2_backward = function (callback) {};
cmd.projs_forward = function (callback) {};
cmd.projs_backward = function (callback) {};
cmd.proj_forward_proj2_backward = function (callback) {};
cmd.proj_backward_proj2_forward = function (callback) {};
/** /**
* Move the camera to a specific frame. Accepts the input with the "move_cam_to" * Move the camera to a specific frame. Accepts the input with the "move_cam_to"

View File

@ -2,6 +2,7 @@ var proj = {};
proj.queue = {}; proj.queue = {};
proj.lock = false; proj.lock = false;
proj.lock2 = false;
proj.init = function () { proj.init = function () {
'use strict'; 'use strict';
proj.listen(); proj.listen();
@ -42,6 +43,64 @@ proj.move = function (callback) {
proj.queue[obj.id] = obj; proj.queue[obj.id] = obj;
proj.lock = true; proj.lock = true;
}; };
proj.set2 = function (dir, callback) {
'use strict';
var obj;
if (proj.lock2) {
return false;
}
obj = {
dir : dir,
second : true,
id : uuid.v4()
};
ipcRenderer.sendSync('proj', obj);
if (typeof callback !== 'undefined') {
obj.callback = callback;
}
proj.queue[obj.id] = obj;
proj.lock2 = true;
};
proj.move2 = function (callback) {
'use strict';
var obj;
if (proj2.lock) {
return false;
}
obj = {
frame : true,
second : true,
id : uuid.v4()
};
ipcRenderer.sendSync('proj', obj);
if (typeof callback !== 'undefined') {
obj.callback = callback;
}
proj.queue[obj.id] = obj;
proj.lock2 = true;
};
proj.both = function (callback) {
'use strict';
var obj;
if (proj.lock || proj2.lock) {
return false;
}
obj = {
frame : true,
both : true,
id : uuid.v4()
};
ipcRenderer.sendSync('proj', obj);
if (typeof callback !== 'undefined') {
obj.callback = callback;
}
proj.queue[obj.id] = obj;
proj.lock = true;
proj.lock2 = true;
}
proj.end = function (c, id, ms) { proj.end = function (c, id, ms) {
'use strict'; 'use strict';
if (c === mcopy.cfg.arduino.cmd.proj_forward) { if (c === mcopy.cfg.arduino.cmd.proj_forward) {
@ -55,6 +114,7 @@ proj.end = function (c, id, ms) {
mcopy.state.projector.pos -= 1; mcopy.state.projector.pos -= 1;
} }
} }
//
if (typeof proj.queue[id] !== 'undefined') { if (typeof proj.queue[id] !== 'undefined') {
if (typeof proj.queue[id].callback !== 'undefined') { if (typeof proj.queue[id].callback !== 'undefined') {
proj.queue[id].callback(ms); proj.queue[id].callback(ms);
@ -78,6 +138,16 @@ proj.setValue = function (val) {
id : uuid.v4() id : uuid.v4()
}; };
ipcRenderer.sendSync('proj', obj); ipcRenderer.sendSync('proj', obj);
} };
proj.setValue2 = function (val) {
'use strict';
var obj = {
val: val,
second : true,
id : uuid.v4()
};
ipcRenderer.sendSync('proj', obj);
};
module.exports = proj; module.exports = proj;

View File

@ -461,6 +461,26 @@ proj.set = async function (dir, id) {
} }
return await proj.end(cmd, id, ms) return await proj.end(cmd, id, ms)
} }
proj.set2 = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.proj2_forward
} else {
cmd = mcopy.cfg.arduino.cmd.proj2_backward
}
proj.state.dir = dir
if (proj.state.digital) {
dig.set(dir)
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(cmd, id, ms)
}
proj.move = async function (frame, id) { proj.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.projector const cmd = mcopy.cfg.arduino.cmd.projector
let ms let ms
@ -482,10 +502,18 @@ proj.move = async function (frame, id) {
proj.listen = function () { proj.listen = function () {
ipcMain.on('proj', async (event, arg) => { ipcMain.on('proj', async (event, arg) => {
if (typeof arg.dir !== 'undefined') { if (typeof arg.dir !== 'undefined') {
try { if (typeof arg.second !== 'undefined') {
await proj.set(arg.dir, arg.id) try {
} catch (err) { await proj.set2(arg.dir, arg.id)
console.error(err) } catch (err) {
console.error(err)
}
} else {
try {
await proj.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} }
} else if (typeof arg.frame !== 'undefined') { } else if (typeof arg.frame !== 'undefined') {
try { try {

View File

@ -36,16 +36,18 @@ mcopy.state = {
pos : 0, pos : 0,
direction: true direction: true
}, },
camera_second : {
pos : 0,
direction : true
},
projector_second : {
pos : 0,
direction : true
}
sequence : { sequence : {
size : 24, size : 24,
arr : ['CF', 'PF'], arr : ['CF', 'PF'],
light : ['255,255,255', ''], light : ['255,255,255', ''],
cmd : {
camera: mcopy.cfg.arduino.cmd.camera,
projector: mcopy.cfg.arduino.cmd.projector,
cam_direction: mcopy.cfg.arduino.cmd.cam_direction,
cam_direction: mcopy.cfg.arduino.cmd.proj_direction
},
pads: { pads: {
cam_forward: 'CF', cam_forward: 'CF',
proj_forward : 'PF', proj_forward : 'PF',

View File

@ -14,4 +14,10 @@ module measurement_bar (X = 20 * IN, Y = 16.4, Z = 3, BOLT = 4, BOLT_OFFSET = (3
} }
} }
projection() measurement_bar(); projection() {
difference () {
measurement_bar();
translate([-11 * IN, 0, 0]) cube([20 * IN, 16.5, 4], center = true);
translate([11 * IN, 0, 0]) cube([20 * IN, 16.5, 4], center = true);
}
}