Allow capper identifier in list of acceptable responses.

This commit is contained in:
Matt McWilliams 2022-06-13 08:08:42 -04:00
parent 04a0330327
commit 585c47d6c7
11 changed files with 63 additions and 15 deletions

View File

@ -179,9 +179,12 @@
"camera_projectors_identifier": "5",
"cameras_projector_identifier": "6",
"cameras_projectors_identifier": "7",
"capper_identifier" : "C",
"camera_capper_identifier" : "8",
"camera_capper_projector_identifier" : "9",
"camera_capper_projectors_identifier" : "0"
"camera_capper_projectors_identifier" : "0",
"cap_on" : "A",
"cap_off" : "B"
}
}
}

View File

@ -100,7 +100,6 @@ class Arduino {
//console.error(err)
return reject(err);
}
//
});
});
}
@ -190,7 +189,8 @@ class Arduino {
let connectSuccess;
this.path[serial] = device;
this.alias[serial] = device;
this.serial[device] = new SerialPort(this.path[serial], {
this.serial[device] = new SerialPort({
path: this.path[serial],
autoOpen: false,
baudRate: cfg.arduino.baud,
parser: parser
@ -242,6 +242,7 @@ class Arduino {
|| data === cfg.arduino.cmd.camera_second_backward
|| data === cfg.arduino.cmd.camera_second
|| data === cfg.arduino.cmd.cameras
|| data === cfg.arduino.cmd.capper_identifier
|| data === cfg.arduino.cmd.camera_capper_identifier
|| data === cfg.arduino.cmd.camera_capper_projector_identifier
|| data === cfg.arduino.cmd.camera_capper_projectors_identifier) {
@ -316,6 +317,9 @@ class Arduino {
else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second';
}
else if (data === cfg.arduino.cmd.capper_identifier) {
type = 'capper';
}
else if (data === cfg.arduino.cmd.camera_capper_identifier) {
type = 'camera,capper';
}
@ -330,6 +334,7 @@ class Arduino {
await delay_1.delay(cfg.arduino.serialDelay);
try {
writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.mcopy_identifier);
this.log.info(writeSuccess);
}
catch (e) {
return reject(e);

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,8 @@ class Camera {
constructor(arduino, cfg, ui, filmout, second = false) {
this.state = {
pos: 0,
dir: true
dir: true,
capepr: false
};
this.arduino = null;
this.intval = null;
@ -80,6 +81,27 @@ class Camera {
}
return await this.end(cmd, id, ms);
}
/**
*
**/
async cap(state, id) {
let cmd;
let ms;
if (state) {
cmd = this.cfg.arduino.cmd[`${this.id}_forward`];
}
else {
cmd = this.cfg.arduino.cmd[`${this.id}_backward`];
}
this.state.capper = state;
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error(err);
}
return await this.end(cmd, id, ms);
}
/**
*
**/
@ -202,6 +224,14 @@ class Camera {
else if (typeof arg.val !== 'undefined') {
this.state.pos = arg.val;
}
else if (typeof arg.capper !== 'undefined') {
try {
await this.cap(arg.capper, arg.id);
}
catch (err) {
this.log.error(err);
}
}
event.returnValue = true;
}
/**

File diff suppressed because one or more lines are too long

View File

@ -501,9 +501,9 @@ class Devices {
}
}
if (capper) {
args.capper = capper;
this.mainWindow.setSize(800, 800);
this.settings.update('capper', capper);
args.capper = capper;
}
this.settings.update('camera', camera);
this.settings.update('projector', projector);

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
#include <Servo.h>
boolean debug_state = true;
boolean debug_state = false;
/*
----------------------------------------------------

View File

@ -179,9 +179,12 @@
"camera_projectors_identifier": "5",
"cameras_projector_identifier": "6",
"cameras_projectors_identifier": "7",
"capper_identifier" : "C",
"camera_capper_identifier" : "8",
"camera_capper_projector_identifier" : "9",
"camera_capper_projectors_identifier" : "0"
"camera_capper_projectors_identifier" : "0",
"cap_on" : "A",
"cap_off" : "B"
}
}
}

View File

@ -108,7 +108,6 @@ class Arduino {
//console.error(err)
return reject(err)
}
//
})
})
}
@ -198,9 +197,10 @@ class Arduino {
async connect (serial : string, device : string, confirm : any) {
return new Promise(async (resolve, reject) => {
let connectSuccess : any
this.path[serial] = device;
this.alias[serial] = device;
this.serial[device] = new SerialPort(this.path[serial], {
this.path[serial] = device
this.alias[serial] = device
this.serial[device] = new SerialPort({
path : this.path[serial],
autoOpen : false,
baudRate: cfg.arduino.baud,
parser: parser
@ -253,6 +253,8 @@ class Arduino {
|| data === cfg.arduino.cmd.camera_second_backward
|| data === cfg.arduino.cmd.camera_second
|| data === cfg.arduino.cmd.cameras
|| data === cfg.arduino.cmd.capper_identifier
|| data === cfg.arduino.cmd.camera_capper_identifier
|| data === cfg.arduino.cmd.camera_capper_projector_identifier
|| data === cfg.arduino.cmd.camera_capper_projectors_identifier) {
@ -317,6 +319,8 @@ class Arduino {
type = 'camera,camera_second,projector'
} else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second'
} else if (data === cfg.arduino.cmd.capper_identifier) {
type = 'capper'
} else if (data === cfg.arduino.cmd.camera_capper_identifier) {
type = 'camera,capper'
} else if (data === cfg.arduino.cmd.camera_capper_projector_identifier) {
@ -326,9 +330,12 @@ class Arduino {
}
return resolve(type)
}
await delay(cfg.arduino.serialDelay)
try {
writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.mcopy_identifier)
this.log.info(writeSuccess)
} catch (e) {
return reject(e)
}

View File

@ -498,9 +498,9 @@ class Devices {
}
if (capper) {
args.capper = capper
this.mainWindow.setSize(800, 800)
this.settings.update('capper', capper)
args.capper = capper
}
this.settings.update('camera', camera)