2018-02-01 19:53:46 +00:00
|
|
|
const cmd = {};
|
2016-06-09 21:21:49 +00:00
|
|
|
|
2019-03-13 19:28:17 +00:00
|
|
|
/**
|
|
|
|
* Move the projector one frame forward
|
|
|
|
*
|
|
|
|
* @param {function} callback Function to call after projector moves one frame
|
|
|
|
**/
|
2016-06-09 21:21:49 +00:00
|
|
|
cmd.proj_forward = function (callback) {
|
|
|
|
'use strict';
|
|
|
|
var res = function (ms) {
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_proj_forward').removeClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
gui.updateState();
|
|
|
|
if (callback) { callback(ms); }
|
|
|
|
};
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_proj_forward').addClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (!mcopy.state.projector.direction) {
|
|
|
|
proj.set(true, function (ms) {
|
|
|
|
setTimeout(function () {
|
|
|
|
proj.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setTimeout(function () {
|
|
|
|
proj.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
}
|
|
|
|
};
|
2019-03-13 19:28:17 +00:00
|
|
|
/**
|
|
|
|
* Move the projector one frame backward
|
|
|
|
*
|
|
|
|
* @param {function} callback Function to call after projector moves one frame
|
|
|
|
**/
|
2016-06-09 21:21:49 +00:00
|
|
|
cmd.proj_backward = function (callback) {
|
|
|
|
'use strict';
|
|
|
|
var res = function (ms) {
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_proj_backward').removeClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
gui.updateState();
|
|
|
|
if (callback) { callback(ms); }
|
|
|
|
};
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_proj_backward').addClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (mcopy.state.projector.direction) {
|
|
|
|
proj.set(false, function (ms) {
|
|
|
|
setTimeout(function () {
|
|
|
|
proj.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setTimeout(function () {
|
|
|
|
proj.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
}
|
|
|
|
};
|
2019-03-13 19:28:17 +00:00
|
|
|
/**
|
|
|
|
* Move the camera one frame forward
|
|
|
|
*
|
2019-03-18 22:41:35 +00:00
|
|
|
* @param {array} rgb Color to set light for frame
|
2019-03-13 19:28:17 +00:00
|
|
|
* @param {function} callback Function to call after camera moves one frame
|
|
|
|
**/
|
2016-06-09 21:21:49 +00:00
|
|
|
cmd.cam_forward = function (rgb, callback) {
|
|
|
|
'use strict';
|
2018-01-09 18:01:19 +00:00
|
|
|
var off = [0, 0, 0];
|
2016-06-09 21:21:49 +00:00
|
|
|
var res = function (ms) {
|
|
|
|
gui.updateState();
|
|
|
|
setTimeout(function () {
|
2018-01-09 18:01:19 +00:00
|
|
|
light.display(off);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(off, function () {
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_cam_forward').removeClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (callback) { callback(ms); }
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
};
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_cam_forward').addClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (!mcopy.state.camera.direction) {
|
|
|
|
cam.set(true, function () {
|
|
|
|
setTimeout( function () {
|
|
|
|
light.display(rgb);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(rgb, function () {
|
2016-06-09 21:21:49 +00:00
|
|
|
setTimeout( function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
light.display(rgb);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(rgb, function () {
|
2016-06-09 21:21:49 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2019-03-18 22:41:35 +00:00
|
|
|
/**
|
|
|
|
* Move the camera one frame forward, light set to black or off
|
|
|
|
*
|
|
|
|
* @param {function} callback Function to call after camera moves one frame
|
|
|
|
**/
|
2016-06-09 21:21:49 +00:00
|
|
|
cmd.black_forward = function (callback) {
|
|
|
|
'use strict';
|
|
|
|
var off = [0, 0, 0];
|
2018-01-09 18:01:19 +00:00
|
|
|
var res = function (ms) {
|
|
|
|
$('#cmd_black_forward').removeClass('active');
|
2018-03-15 01:06:39 +00:00
|
|
|
gui.updateState();
|
|
|
|
if (callback) { callback(ms); }
|
2018-01-09 18:01:19 +00:00
|
|
|
};
|
|
|
|
$('#cmd_black_forward').addClass('active');
|
|
|
|
if (!mcopy.state.camera.direction) {
|
|
|
|
cam.set(true, function () {
|
|
|
|
setTimeout( function () {
|
|
|
|
light.display(off);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(off, function () {
|
2018-01-09 18:01:19 +00:00
|
|
|
setTimeout( function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
light.display(off);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(off, function () {
|
2018-01-09 18:01:19 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}
|
2016-06-09 21:21:49 +00:00
|
|
|
};
|
2019-03-18 22:41:35 +00:00
|
|
|
/**
|
|
|
|
* Move the camera one frame backward
|
|
|
|
*
|
|
|
|
* @param {array} rgb Color to set light for frame
|
|
|
|
* @param {function} callback Function to call after camera moves one frame
|
|
|
|
**/
|
2016-06-09 21:21:49 +00:00
|
|
|
cmd.cam_backward = function (rgb, callback) {
|
|
|
|
'use strict';
|
2018-01-09 18:01:19 +00:00
|
|
|
var off = [0, 0, 0];
|
2016-06-09 21:21:49 +00:00
|
|
|
var res = function (ms) {
|
|
|
|
gui.updateState();
|
2018-01-09 18:01:19 +00:00
|
|
|
light.display(off);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(off, function () {
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_cam_backward').removeClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (callback) { callback(ms); }
|
|
|
|
});
|
|
|
|
};
|
2018-01-21 00:51:08 +00:00
|
|
|
$('#cmd_cam_backward').addClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (mcopy.state.camera.direction) {
|
|
|
|
cam.set(false, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(rgb);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(rgb, function () {
|
2016-06-09 21:21:49 +00:00
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(rgb);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(rgb, function () {
|
2016-06-09 21:21:49 +00:00
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
}
|
|
|
|
};
|
2019-03-18 22:41:35 +00:00
|
|
|
/**
|
|
|
|
* Move the camera one frame forward, light set to black or off
|
|
|
|
*
|
|
|
|
* @param {function} callback Function to call after camera moves one frame
|
|
|
|
**/
|
2016-06-09 21:21:49 +00:00
|
|
|
cmd.black_backward = function (callback) {
|
|
|
|
'use strict';
|
|
|
|
var off = [0, 0, 0];
|
2018-01-09 18:01:19 +00:00
|
|
|
var res = function (ms) {
|
|
|
|
$('#cmd_black_backward').removeClass('active');
|
|
|
|
gui.updateState();
|
2018-03-15 01:06:39 +00:00
|
|
|
if (callback) { callback(ms); }
|
2018-01-09 18:01:19 +00:00
|
|
|
};
|
2018-01-21 00:51:08 +00:00
|
|
|
$('#cmd_black_backward').addClass('active');
|
2018-01-09 18:01:19 +00:00
|
|
|
if (mcopy.state.camera.direction) {
|
|
|
|
cam.set(false, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(off);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(off, function () {
|
2018-01-09 18:01:19 +00:00
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(off);
|
2019-02-13 23:57:18 +00:00
|
|
|
light.set(off, function () {
|
2018-01-09 18:01:19 +00:00
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
}
|
2016-06-09 21:21:49 +00:00
|
|
|
};
|
2019-03-20 19:44:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
cam2_forward : 'C2F',
|
|
|
|
cam2_backward : 'C2B',
|
|
|
|
|
|
|
|
cams_forward : 'CCF',
|
|
|
|
cams_forward : 'CCB',
|
|
|
|
|
|
|
|
cam_forward_cam2_backward : 'CFCB',
|
|
|
|
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'
|
|
|
|
*/
|
|
|
|
|
2019-03-18 23:42:12 +00:00
|
|
|
/**
|
|
|
|
* Move the camera to a specific frame. Accepts the input with the "move_cam_to"
|
|
|
|
* value. Moves as black frames to prevent multiple exposure.
|
|
|
|
*
|
|
|
|
* @param {object} t HTML input element with the move to val
|
|
|
|
**/
|
2018-02-01 19:53:46 +00:00
|
|
|
cmd.cam_to = function (t) {
|
2018-03-15 01:06:39 +00:00
|
|
|
const raw = $('#move_cam_to').val();
|
|
|
|
const val = parseInt(raw);
|
|
|
|
let proceed = false;
|
|
|
|
let total;
|
|
|
|
let steps = [];
|
|
|
|
let c;
|
|
|
|
let cont;
|
2018-02-01 19:53:46 +00:00
|
|
|
if (val !== mcopy.state.camera.pos) {
|
|
|
|
if (val < mcopy.state.camera.pos) {
|
2018-03-15 01:06:39 +00:00
|
|
|
total = -(mcopy.state.camera.pos - val)
|
2018-02-01 19:53:46 +00:00
|
|
|
} else if (val > mcopy.state.camera.pos) {
|
|
|
|
total = val - mcopy.state.camera.pos
|
|
|
|
}
|
2018-03-15 01:06:39 +00:00
|
|
|
if (total > 0) {
|
|
|
|
c = 'BF';
|
|
|
|
} else if (total < 0) {
|
|
|
|
c = 'BB';
|
|
|
|
}
|
|
|
|
for (let i = 0; i < Math.abs(total); i++) {
|
|
|
|
steps.push({ cmd : c })
|
|
|
|
}
|
|
|
|
cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the camera ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`)
|
|
|
|
if (cont) {
|
|
|
|
seq.exec(steps);
|
|
|
|
}
|
2018-02-01 19:53:46 +00:00
|
|
|
}
|
|
|
|
};
|
2019-03-20 19:44:07 +00:00
|
|
|
/**
|
|
|
|
* Move the projector to a specific frame. Accepts the input with the "move_proj_to"
|
|
|
|
* value.
|
|
|
|
*
|
|
|
|
* @param {object} t HTML input element with the move to val
|
|
|
|
**/
|
2018-02-01 19:53:46 +00:00
|
|
|
cmd.proj_to = function (t) {
|
2018-03-15 01:06:39 +00:00
|
|
|
const raw = $('#move_proj_to').val();
|
|
|
|
const val = parseInt(raw);
|
|
|
|
let proceed = false;
|
|
|
|
let total;
|
|
|
|
let steps = [];
|
|
|
|
let c;
|
|
|
|
let cont
|
2018-02-01 19:53:46 +00:00
|
|
|
if (val !== mcopy.state.projector.pos) {
|
|
|
|
if (val < mcopy.state.projector.pos) {
|
2018-03-15 01:06:39 +00:00
|
|
|
total = -(mcopy.state.projector.pos - val)
|
2018-02-01 19:53:46 +00:00
|
|
|
} else if (val > mcopy.state.projector.pos) {
|
|
|
|
total = val - mcopy.state.projector.pos
|
|
|
|
}
|
2018-03-15 01:06:39 +00:00
|
|
|
if (total > 0) {
|
|
|
|
c = 'PF';
|
|
|
|
} else if (total < 0) {
|
|
|
|
c = 'PB';
|
|
|
|
}
|
|
|
|
for (let i = 0; i < Math.abs(total); i++) {
|
|
|
|
steps.push({ cmd : c })
|
|
|
|
}
|
|
|
|
cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the projector ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`)
|
|
|
|
if (cont) {
|
|
|
|
seq.exec(steps);
|
|
|
|
}
|
2018-02-01 19:53:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-09 21:21:49 +00:00
|
|
|
module.exports = cmd;
|