2016-06-09 21:21:49 +00:00
|
|
|
var cmd = {};
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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);
|
|
|
|
light.set(off, function () {
|
|
|
|
$('#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);
|
|
|
|
light.set(rgb, function () {
|
|
|
|
setTimeout( function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
light.display(rgb);
|
|
|
|
light.set(rgb, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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');
|
|
|
|
gui.updateState();
|
|
|
|
};
|
|
|
|
$('#cmd_black_forward').addClass('active');
|
|
|
|
if (!mcopy.state.camera.direction) {
|
|
|
|
cam.set(true, function () {
|
|
|
|
setTimeout( function () {
|
|
|
|
light.display(off);
|
|
|
|
light.set(off, function () {
|
|
|
|
setTimeout( function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
light.display(off);
|
|
|
|
light.set(off, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
cam.move(res);
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
}
|
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);
|
|
|
|
light.set(off, function () {
|
|
|
|
$('#cmd_cam_backward').removeClass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (callback) { callback(ms); }
|
|
|
|
});
|
|
|
|
};
|
2018-01-09 18:01:19 +00:00
|
|
|
$('#cmd_cam_backward').addlass('active');
|
2016-06-09 21:21:49 +00:00
|
|
|
if (mcopy.state.camera.direction) {
|
|
|
|
cam.set(false, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(rgb);
|
|
|
|
light.set(rgb, function () {
|
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(rgb);
|
|
|
|
light.set(rgb, function () {
|
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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();
|
|
|
|
};
|
|
|
|
$('#cmd_black_backward').addlass('active');
|
|
|
|
if (mcopy.state.camera.direction) {
|
|
|
|
cam.set(false, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(off);
|
|
|
|
light.set(off, function () {
|
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setTimeout(function () {
|
|
|
|
light.display(off);
|
|
|
|
light.set(off, function () {
|
|
|
|
cam.move(res);
|
|
|
|
});
|
|
|
|
}, mcopy.cfg.arduino.serialDelay);
|
|
|
|
}
|
2016-06-09 21:21:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = cmd;
|