Okay. Removed the light.state.on behavior. Now, a frame is rendered to the set color state of the "light" only when the camera is moving. Unnecessary frames don't display AND the correct color is represented at the right time. No juggling state values between steps in the sequence.

This commit is contained in:
mmcwilliams 2019-02-13 18:57:18 -05:00
parent e7ac873f41
commit 8fd29e89d8
4 changed files with 15 additions and 19 deletions

View File

@ -27,7 +27,7 @@ async function frame (state, light) {
let h = state.info.height
let padded = padded_frame(frame)
let ext = 'tif'
let rgb = light.on;
let rgb = light.color;
let tmpoutput
let cmd
let output

View File

@ -47,7 +47,7 @@ cmd.cam_forward = function (rgb, callback) {
gui.updateState();
setTimeout(function () {
light.display(off);
light.set(off, false, function () {
light.set(off, function () {
$('#cmd_cam_forward').removeClass('active');
if (callback) { callback(ms); }
});
@ -58,7 +58,7 @@ cmd.cam_forward = function (rgb, callback) {
cam.set(true, function () {
setTimeout( function () {
light.display(rgb);
light.set(rgb, true, function () {
light.set(rgb, function () {
setTimeout( function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
@ -67,7 +67,7 @@ cmd.cam_forward = function (rgb, callback) {
});
} else {
light.display(rgb);
light.set(rgb, true, function () {
light.set(rgb, function () {
setTimeout(function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
@ -87,7 +87,7 @@ cmd.black_forward = function (callback) {
cam.set(true, function () {
setTimeout( function () {
light.display(off);
light.set(off, false, function () {
light.set(off, function () {
setTimeout( function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
@ -96,7 +96,7 @@ cmd.black_forward = function (callback) {
});
} else {
light.display(off);
light.set(off, false, function () {
light.set(off, function () {
setTimeout(function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
@ -109,7 +109,7 @@ cmd.cam_backward = function (rgb, callback) {
var res = function (ms) {
gui.updateState();
light.display(off);
light.set(off, false, function () {
light.set(off, function () {
$('#cmd_cam_backward').removeClass('active');
if (callback) { callback(ms); }
});
@ -119,7 +119,7 @@ cmd.cam_backward = function (rgb, callback) {
cam.set(false, function () {
setTimeout(function () {
light.display(rgb);
light.set(rgb, true, function () {
light.set(rgb, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);
@ -127,7 +127,7 @@ cmd.cam_backward = function (rgb, callback) {
} else {
setTimeout(function () {
light.display(rgb);
light.set(rgb, true, function () {
light.set(rgb, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);
@ -146,7 +146,7 @@ cmd.black_backward = function (callback) {
cam.set(false, function () {
setTimeout(function () {
light.display(off);
light.set(off, false, function () {
light.set(off, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);
@ -154,7 +154,7 @@ cmd.black_backward = function (callback) {
} else {
setTimeout(function () {
light.display(off);
light.set(off, false, function () {
light.set(off, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);

View File

@ -111,7 +111,7 @@ light.colorPickers = function () {
light.kelvin.init();
//light.cmy.init();
};
light.set = function (rgb, on, callback) { //rgb = [0,0,0]
light.set = function (rgb, callback) { //rgb = [0,0,0]
'use strict';
var obj;
@ -122,8 +122,7 @@ light.set = function (rgb, on, callback) { //rgb = [0,0,0]
obj = {
rgb,
id : uuid.v4(),
on
id : uuid.v4()
};
ipcRenderer.sendSync('light', obj);

View File

@ -363,8 +363,7 @@ var createWindow = function () {
}
light.state = {
color : [0, 0, 0],
on : [0, 0, 0]
color : [0, 0, 0]
}
light.init = function () {
@ -373,7 +372,7 @@ light.init = function () {
light.listen = function () {
ipcMain.on('light', async (event, arg) => {
try {
await light.set(arg.rgb, arg.id, arg.on)
await light.set(arg.rgb, arg.id)
}catch (err) {
console.error(err)
return reject(err)
@ -385,8 +384,6 @@ light.set = async function (rgb, id, on) {
const str = rgb.join(',');
let ms
light.state.color = rgb;
if (on) light.state.on = rgb;
console.dir(light.state)
try {
ms = arduino.send('light', mcopy.cfg.arduino.cmd.light)
} catch (err) {