Merge in 9 months of work on capper branch #71

Merged
mattmcw merged 95 commits from capper into main 2023-02-19 05:28:46 +00:00
11 changed files with 63 additions and 15 deletions
Showing only changes of commit 585c47d6c7 - Show all commits

View File

@ -179,9 +179,12 @@
"camera_projectors_identifier": "5", "camera_projectors_identifier": "5",
"cameras_projector_identifier": "6", "cameras_projector_identifier": "6",
"cameras_projectors_identifier": "7", "cameras_projectors_identifier": "7",
"capper_identifier" : "C",
"camera_capper_identifier" : "8", "camera_capper_identifier" : "8",
"camera_capper_projector_identifier" : "9", "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) //console.error(err)
return reject(err); return reject(err);
} }
//
}); });
}); });
} }
@ -190,7 +189,8 @@ class Arduino {
let connectSuccess; let connectSuccess;
this.path[serial] = device; this.path[serial] = device;
this.alias[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, autoOpen: false,
baudRate: cfg.arduino.baud, baudRate: cfg.arduino.baud,
parser: parser parser: parser
@ -242,6 +242,7 @@ class Arduino {
|| data === cfg.arduino.cmd.camera_second_backward || data === cfg.arduino.cmd.camera_second_backward
|| data === cfg.arduino.cmd.camera_second || data === cfg.arduino.cmd.camera_second
|| data === cfg.arduino.cmd.cameras || data === cfg.arduino.cmd.cameras
|| data === cfg.arduino.cmd.capper_identifier
|| data === cfg.arduino.cmd.camera_capper_identifier || data === cfg.arduino.cmd.camera_capper_identifier
|| data === cfg.arduino.cmd.camera_capper_projector_identifier || data === cfg.arduino.cmd.camera_capper_projector_identifier
|| data === cfg.arduino.cmd.camera_capper_projectors_identifier) { || data === cfg.arduino.cmd.camera_capper_projectors_identifier) {
@ -316,6 +317,9 @@ class Arduino {
else if (data === cfg.arduino.cmd.cameras_projectors_identifier) { else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second'; 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) { else if (data === cfg.arduino.cmd.camera_capper_identifier) {
type = 'camera,capper'; type = 'camera,capper';
} }
@ -330,6 +334,7 @@ class Arduino {
await delay_1.delay(cfg.arduino.serialDelay); await delay_1.delay(cfg.arduino.serialDelay);
try { try {
writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.mcopy_identifier); writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.mcopy_identifier);
this.log.info(writeSuccess);
} }
catch (e) { catch (e) {
return reject(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) { constructor(arduino, cfg, ui, filmout, second = false) {
this.state = { this.state = {
pos: 0, pos: 0,
dir: true dir: true,
capepr: false
}; };
this.arduino = null; this.arduino = null;
this.intval = null; this.intval = null;
@ -80,6 +81,27 @@ class Camera {
} }
return await this.end(cmd, id, ms); 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') { else if (typeof arg.val !== 'undefined') {
this.state.pos = arg.val; 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; event.returnValue = true;
} }
/** /**

File diff suppressed because one or more lines are too long

View File

@ -501,9 +501,9 @@ class Devices {
} }
} }
if (capper) { if (capper) {
args.capper = capper;
this.mainWindow.setSize(800, 800); this.mainWindow.setSize(800, 800);
this.settings.update('capper', capper); this.settings.update('capper', capper);
args.capper = capper;
} }
this.settings.update('camera', camera); this.settings.update('camera', camera);
this.settings.update('projector', projector); 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> #include <Servo.h>
boolean debug_state = true; boolean debug_state = false;
/* /*
---------------------------------------------------- ----------------------------------------------------

View File

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

View File

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