Fixed serialization error that was breaking raspberry pi 4 installation. It is apparently a real bug that should be breaking the app.

This commit is contained in:
sixteenmillimeter 2020-07-26 21:52:53 -04:00
parent e5e4c7ded7
commit 5c691a8e12
10 changed files with 135 additions and 73 deletions

View File

@ -1,5 +1,6 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const uuid_1 = require("uuid");
const delay_1 = require("delay");
class Commands {
/**
@ -72,6 +73,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -80,11 +82,11 @@ class Commands {
await this.cam.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -97,6 +99,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async black_forward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -105,11 +108,11 @@ class Commands {
await this.cam.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off); //make sure set to off
await this.light.set(off, id); //make sure set to off
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -124,6 +127,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -132,11 +136,11 @@ class Commands {
await this.cam.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -149,6 +153,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async black_backward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -157,11 +162,11 @@ class Commands {
await this.cam.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off); //make sure set to off
await this.light.set(off, id); //make sure set to off
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -176,6 +181,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_second_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -184,11 +190,11 @@ class Commands {
await this.cam2.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -203,6 +209,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_second_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -211,11 +218,11 @@ class Commands {
await this.cam2.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -230,6 +237,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async cameras_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -243,7 +251,7 @@ class Commands {
await this.cam2.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -255,7 +263,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -270,6 +278,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async cameras_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -283,7 +292,7 @@ class Commands {
await this.cam2.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -295,7 +304,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -310,6 +319,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -323,7 +333,7 @@ class Commands {
await this.cam2.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -335,7 +345,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -350,6 +360,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -363,7 +374,7 @@ class Commands {
await this.cam2.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -375,7 +386,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;

File diff suppressed because one or more lines are too long

View File

@ -52,12 +52,12 @@ class Light {
/**
*
**/
async set(rgb, id, on) {
async set(rgb, id, on = true) {
const str = rgb.join(',');
let ms;
this.state.color = rgb;
try {
ms = this.arduino.send(this.id, this.cfg.arduino.cmd.light);
ms = await this.arduino.send(this.id, this.cfg.arduino.cmd.light);
}
catch (err) {
this.log.error('Error sending light command', err);
@ -77,8 +77,18 @@ class Light {
*
**/
async end(rgb, id, ms) {
let res;
//console.trace()
this.log.info(`Light set to ${rgb.join(',')}`, 'LIGHT', true, true);
return await this.ui.send(this.id, { rgb: rgb, id: id, ms: ms });
try {
//console.dir({ rgb, id, ms })
res = await this.ui.send(this.id, { rgb, id, ms });
}
catch (err) {
console.error(err);
throw err;
}
return res;
}
}
module.exports = function (arduino, cfg, ui) {

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/light/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,iCAA8B;AAC9B,2BAA4B;AAE5B,MAAM,KAAK;IAYV;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ;QAd5C,UAAK,GAAS,EAAE,KAAK,EAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;QAOlC,YAAO,GAAa,IAAI,CAAC;QAEzB,OAAE,GAAY,OA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ACD,MAAM,aAAK,CAAC,CAAC,CAAC,CAAC;QACf,MAAM,EAAE,CAAC;QACT,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,GAAG,CAAE,GAAc,EAAE,EAAW,EAAE,EAAW;QAC1D,IAAI,GAAG,CAAC;QACR,iBAAiB;QACjB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACpE,IAAI;YACH,8BAA8B;YAC9B,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;SACnD;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,MAAM,GAAG,CAAA;SACT;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,OAAiB,EAAE,GAAS,EAAE,EAAQ;IAChE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC,CAAA"}

View File

@ -1,5 +1,6 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const uuid_1 = require("uuid");
const delay_1 = require("delay");
class Commands {
/**
@ -72,6 +73,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -80,11 +82,11 @@ class Commands {
await this.cam.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -97,6 +99,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async black_forward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -105,11 +108,11 @@ class Commands {
await this.cam.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off); //make sure set to off
await this.light.set(off, id); //make sure set to off
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -124,6 +127,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -132,11 +136,11 @@ class Commands {
await this.cam.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -149,6 +153,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async black_backward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -157,11 +162,11 @@ class Commands {
await this.cam.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off); //make sure set to off
await this.light.set(off, id); //make sure set to off
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -176,6 +181,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_second_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -184,11 +190,11 @@ class Commands {
await this.cam2.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -203,6 +209,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_second_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let ms;
try {
@ -211,11 +218,11 @@ class Commands {
await this.cam2.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -230,6 +237,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async cameras_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -243,7 +251,7 @@ class Commands {
await this.cam2.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -255,7 +263,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -270,6 +278,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async cameras_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -283,7 +292,7 @@ class Commands {
await this.cam2.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -295,7 +304,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -310,6 +319,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -323,7 +333,7 @@ class Commands {
await this.cam2.set(false);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -335,7 +345,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;
@ -350,6 +360,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
const off = [0, 0, 0];
let both;
let ms;
@ -363,7 +374,7 @@ class Commands {
await this.cam2.set(true);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay_1.delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
ms = await this.cam.both();
@ -375,7 +386,7 @@ class Commands {
ms = Math.max(...both);
}
await delay_1.delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
}
catch (err) {
throw err;

File diff suppressed because one or more lines are too long

View File

@ -52,12 +52,12 @@ class Light {
/**
*
**/
async set(rgb, id, on) {
async set(rgb, id, on = true) {
const str = rgb.join(',');
let ms;
this.state.color = rgb;
try {
ms = this.arduino.send(this.id, this.cfg.arduino.cmd.light);
ms = await this.arduino.send(this.id, this.cfg.arduino.cmd.light);
}
catch (err) {
this.log.error('Error sending light command', err);
@ -77,8 +77,18 @@ class Light {
*
**/
async end(rgb, id, ms) {
let res;
//console.trace()
this.log.info(`Light set to ${rgb.join(',')}`, 'LIGHT', true, true);
return await this.ui.send(this.id, { rgb: rgb, id: id, ms: ms });
try {
//console.dir({ rgb, id, ms })
res = await this.ui.send(this.id, { rgb, id, ms });
}
catch (err) {
console.error(err);
throw err;
}
return res;
}
}
module.exports = function (arduino, cfg, ui) {

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/light/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,iCAA8B;AAC9B,2BAA4B;AAE5B,MAAM,KAAK;IAYV;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ;QAd5C,UAAK,GAAS,EAAE,KAAK,EAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;QAOlC,YAAO,GAAa,IAAI,CAAC;QAEzB,OAAE,GAAY,OAAO,CAAC;QAM7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAED;;QAEI;IACI,MAAM;QACb,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC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AAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;SACnD;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,MAAM,GAAG,CAAA;SACT;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,OAAiB,EAAE,GAAS,EAAE,EAAQ;IAChE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC,CAAA"}

View File

@ -1,5 +1,6 @@
'use strict';
import { v4 as uuid } from 'uuid';
import { delay } from 'delay';
class Commands {
@ -83,6 +84,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async camera_forward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let ms : number;
try {
@ -91,11 +93,11 @@ class Commands {
await this.cam.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -107,6 +109,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async black_forward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let ms : number;
try {
@ -115,11 +118,11 @@ class Commands {
await this.cam.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off); //make sure set to off
await this.light.set(off, id); //make sure set to off
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -133,6 +136,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async camera_backward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let ms : number;
try {
@ -141,11 +145,11 @@ class Commands {
await this.cam.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -157,6 +161,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async black_backward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let ms : number;
try {
@ -165,11 +170,11 @@ class Commands {
await this.cam.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off); //make sure set to off
await this.light.set(off, id); //make sure set to off
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -184,6 +189,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async camera_second_forward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let ms : number;
try {
@ -192,11 +198,11 @@ class Commands {
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -211,6 +217,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async camera_second_backward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let ms : number;
try {
@ -219,11 +226,11 @@ class Commands {
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -239,6 +246,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async cameras_forward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
@ -252,7 +260,7 @@ class Commands {
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
@ -265,7 +273,7 @@ class Commands {
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -279,6 +287,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async cameras_backward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
@ -292,7 +301,7 @@ class Commands {
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
@ -305,7 +314,7 @@ class Commands {
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -320,6 +329,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async camera_forward_camera_second_backward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
@ -333,7 +343,7 @@ class Commands {
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
@ -346,7 +356,7 @@ class Commands {
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}
@ -360,6 +370,7 @@ class Commands {
* @returns {integer} Length of action in ms
**/
public async camera_backward_camera_second_forward (rgb : number[] = [255, 255, 255]) {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
@ -373,7 +384,7 @@ class Commands {
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await this.light.set(rgb, id);
await delay(this.cfg.arduino.serialDelay);
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
@ -386,7 +397,7 @@ class Commands {
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
await this.light.set(off, id);
} catch (err) {
throw err;
}

View File

@ -63,13 +63,13 @@ class Light {
/**
*
**/
public async set (rgb : number[], id : string, on : boolean) {
public async set (rgb : number[], id : string, on : boolean = true) {
const str : string = rgb.join(',');
let ms : any;
this.state.color = rgb;
try {
ms = this.arduino.send(this.id, this.cfg.arduino.cmd.light);
ms = await this.arduino.send(this.id, this.cfg.arduino.cmd.light);
} catch (err) {
this.log.error('Error sending light command', err);
}
@ -88,8 +88,17 @@ class Light {
*
**/
private async end (rgb : number[], id : string, ms : number) {
let res;
//console.trace()
this.log.info(`Light set to ${rgb.join(',')}`, 'LIGHT', true, true);
return await this.ui.send(this.id, { rgb: rgb, id : id, ms: ms });
try {
//console.dir({ rgb, id, ms })
res = await this.ui.send(this.id, { rgb, id, ms });
} catch (err) {
console.error(err);
throw err
}
return res;
}
}