Create a "digital" module, moving the "dig" object from the main.js process to it's own class.
This commit is contained in:
parent
72575ce2a4
commit
fce259d29b
|
@ -0,0 +1,56 @@
|
|||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const delay = require("delay");
|
||||
const dig = {};
|
||||
dig.state = {
|
||||
frame: 0,
|
||||
frames: 0,
|
||||
path: null,
|
||||
fileName: null,
|
||||
info: {},
|
||||
dir: true
|
||||
};
|
||||
dig.set = function (dir) {
|
||||
dig.state.dir = dir;
|
||||
};
|
||||
dig.move = async function () {
|
||||
let start = +new Date();
|
||||
let last = dig.state.dir + 0;
|
||||
if (dig.state.dir) {
|
||||
dig.state.frame++;
|
||||
}
|
||||
else {
|
||||
dig.state.frame--;
|
||||
}
|
||||
if (dig.state.frame < 1) {
|
||||
dig.state.frame = 1;
|
||||
}
|
||||
return (+new Date()) - start;
|
||||
};
|
||||
dig.start = async function (lightState) {
|
||||
try {
|
||||
await dig.ffmpeg.clearAll();
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
try {
|
||||
await dig.ffmpeg.frame(dig.state, lightState);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
dig.display.start(dig.state.frame);
|
||||
await delay(20);
|
||||
};
|
||||
dig.end = async function () {
|
||||
await delay(20);
|
||||
dig.display.end();
|
||||
};
|
||||
module.exports = (display, ffmpeg, ffprobe) => {
|
||||
dig.display = display;
|
||||
dig.ffmpeg = ffmpeg;
|
||||
dig.ffprobe = ffprobe;
|
||||
return dig;
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/digital/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+BAAgC;AAEhC,MAAM,GAAG,GAAS,EAAE,CAAC;AACrB,GAAG,CAAC,KAAK,GAAG;IACX,KAAK,EAAG,CAAC;IACT,MAAM,EAAG,CAAC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AC,EAAE,CAAC,CAAA;AAChB,CAAC,CAAA;AAED,GAAG,CAAC,GAAG,GAAG,KAAK;IACd,MAAM,KAAK,CAAC,EAAE,CAAC,CAAA;IACf,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,OAAa,EAAE,MAAY,EAAE,OAAa,EAAE,EAAE;IAC/D,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,OAAO,GAAG,CAAC;AACZ,CAAC,CAAA"}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "digital",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
|
@ -1536,6 +1536,9 @@
|
|||
"kuler": "1.0.x"
|
||||
}
|
||||
},
|
||||
"digital": {
|
||||
"version": "file:lib/digital"
|
||||
},
|
||||
"display": {
|
||||
"version": "file:lib/display"
|
||||
},
|
||||
|
@ -4275,6 +4278,9 @@
|
|||
"resolve": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"light": {
|
||||
"version": "file:lib/light"
|
||||
},
|
||||
"load-json-file": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
|
||||
|
@ -5699,6 +5705,9 @@
|
|||
"through2": "~0.2.3"
|
||||
}
|
||||
},
|
||||
"proj": {
|
||||
"version": "file:lib/proj"
|
||||
},
|
||||
"promise": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "http://registry.npmjs.org/promise/-/promise-1.3.0.tgz",
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
"cam": "file:lib/cam",
|
||||
"capture": "file:lib/capture",
|
||||
"delay": "file:lib/delay",
|
||||
"digital": "file:lib/digital",
|
||||
"display": "file:lib/display",
|
||||
"electron-updater": "^4.0.6",
|
||||
"exec": "file:lib/exec",
|
||||
|
@ -52,10 +53,12 @@
|
|||
"fs-extra": "^7.0.1",
|
||||
"humanize-duration": "^3.15.1",
|
||||
"intval": "file:lib/intval",
|
||||
"light": "file:lib/light",
|
||||
"log": "file:lib/log",
|
||||
"moment": "^2.22.2",
|
||||
"mscript": "file:lib/mscript",
|
||||
"node-notifier": "^5.3.0",
|
||||
"proj": "file:lib/proj",
|
||||
"serialport": "^7.0.2",
|
||||
"server": "file:lib/server",
|
||||
"settings": "file:lib/settings",
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const delay = require("delay");
|
||||
const dig = {};
|
||||
dig.state = {
|
||||
frame: 0,
|
||||
frames: 0,
|
||||
path: null,
|
||||
fileName: null,
|
||||
info: {},
|
||||
dir: true
|
||||
};
|
||||
dig.set = function (dir) {
|
||||
dig.state.dir = dir;
|
||||
};
|
||||
dig.move = async function () {
|
||||
let start = +new Date();
|
||||
let last = dig.state.dir + 0;
|
||||
if (dig.state.dir) {
|
||||
dig.state.frame++;
|
||||
}
|
||||
else {
|
||||
dig.state.frame--;
|
||||
}
|
||||
if (dig.state.frame < 1) {
|
||||
dig.state.frame = 1;
|
||||
}
|
||||
return (+new Date()) - start;
|
||||
};
|
||||
dig.start = async function (lightState) {
|
||||
try {
|
||||
await dig.ffmpeg.clearAll();
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
try {
|
||||
await dig.ffmpeg.frame(dig.state, lightState);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
dig.display.start(dig.state.frame);
|
||||
await delay(20);
|
||||
};
|
||||
dig.end = async function () {
|
||||
await delay(20);
|
||||
dig.display.end();
|
||||
};
|
||||
module.exports = (display, ffmpeg, ffprobe) => {
|
||||
dig.display = display;
|
||||
dig.ffmpeg = ffmpeg;
|
||||
dig.ffprobe = ffprobe;
|
||||
return dig;
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/digital/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+BAAgC;AAEhC,MAAM,GAAG,GAAS,EAAE,CAAC;AACrB,GAAG,CAAC,KAAK,GAAG;IACX,KAAK,EAAG,CAAC;IACT,MAAM,EAAG,CAAC;IACV,IAAI,EAAG,IAAI;IACX,QAAQ,EAAG,IAAI;IACf,IAAI,EAAG,EAAE;IACT,GAAG,EAAG,IAAI;CACV,CAAC;AAEF,GAAG,CAAC,GAAG,GAAI,UAAU,GAAa;IACjC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;AACrB,CAAC,CAAA;AAED,GAAG,CAAC,IAAI,GAAG,KAAK;IACf,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,EAAE,CAAA;IACvB,IAAI,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IAC7B,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE;QAClB,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;KACjB;SAAM;QACN,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;KACjB;IACD,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE;QACxB,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAA;KACnB;IACD,OAAO,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,KAAK,CAAA;AAC7B,CAAC,CAAA;AAED,GAAG,CAAC,KAAK,GAAG,KAAK,WAAW,UAAoB;IAC/C,IAAI;QACH,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;KAC3B;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KAClB;IAED,IAAI;QACH,MAAM,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;KAC7C;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KAClB;IAED,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAClC,MAAM,KAAK,CAAC,EAAE,CAAC,CAAA;AAChB,CAAC,CAAA;AAED,GAAG,CAAC,GAAG,GAAG,KAAK;IACd,MAAM,KAAK,CAAC,EAAE,CAAC,CAAA;IACf,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,OAAa,EAAE,MAAY,EAAE,OAAa,EAAE,EAAE;IAC/D,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,OAAO,GAAG,CAAC;AACZ,CAAC,CAAA"}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "digital",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const delay = require("delay");
|
||||
const dig = {};
|
||||
dig.state = {
|
||||
frame: 0,
|
||||
frames: 0,
|
||||
path: null,
|
||||
fileName: null,
|
||||
info: {},
|
||||
dir: true
|
||||
};
|
||||
dig.set = function (dir) {
|
||||
dig.state.dir = dir;
|
||||
};
|
||||
dig.move = async function () {
|
||||
let start = +new Date();
|
||||
let last = dig.state.dir + 0;
|
||||
if (dig.state.dir) {
|
||||
dig.state.frame++;
|
||||
}
|
||||
else {
|
||||
dig.state.frame--;
|
||||
}
|
||||
if (dig.state.frame < 1) {
|
||||
dig.state.frame = 1;
|
||||
}
|
||||
return (+new Date()) - start;
|
||||
};
|
||||
dig.start = async function (lightState) {
|
||||
try {
|
||||
await dig.ffmpeg.clearAll();
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
try {
|
||||
await dig.ffmpeg.frame(dig.state, lightState);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
dig.display.start(dig.state.frame);
|
||||
await delay(20);
|
||||
};
|
||||
dig.end = async function () {
|
||||
await delay(20);
|
||||
dig.display.end();
|
||||
};
|
||||
module.exports = (display, ffmpeg, ffprobe) => {
|
||||
dig.display = display;
|
||||
dig.ffmpeg = ffmpeg;
|
||||
dig.ffprobe = ffprobe;
|
||||
return dig;
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/digital/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+BAAgC;AAEhC,MAAM,GAAG,GAAS,EAAE,CAAC;AACrB,GAAG,CAAC,KAAK,GAAG;IACX,KAAK,EAAG,CAAC;IACT,MAAM,EAAG,CAAC;IACV,IAAI,EAAG,IAAI;IACX,QAAQ,EAAG,IAAI;IACf,IAAI,EAAG,EAAE;IACT,GAAG,EAAG,IAAI;CACV,CAAC;AAEF,GAAG,CAAC,GAAG,GAAI,UAAU,GAAa;IACjC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;AACrB,CAAC,CAAA;AAED,GAAG,CAAC,IAAI,GAAG,KAAK;IACf,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,EAAE,CAAA;IACvB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,CAAC,MAAM,GAAG,MAAM,CAAC;IACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,OAAO,GAAG,CAAC;AACZ,CAAC,CAAA"}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "digital",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
'use strict';
|
||||
|
||||
import delay = require('delay');
|
||||
|
||||
const dig : any = {};
|
||||
dig.state = {
|
||||
frame : 0,
|
||||
frames : 0,
|
||||
path : null,
|
||||
fileName : null,
|
||||
info : {},
|
||||
dir : true
|
||||
};
|
||||
|
||||
dig.set = function (dir : boolean) {
|
||||
dig.state.dir = dir;
|
||||
}
|
||||
|
||||
dig.move = async function () {
|
||||
let start = +new Date()
|
||||
let last = dig.state.dir + 0;
|
||||
if (dig.state.dir) {
|
||||
dig.state.frame++
|
||||
} else {
|
||||
dig.state.frame--
|
||||
}
|
||||
if (dig.state.frame < 1) {
|
||||
dig.state.frame = 1
|
||||
}
|
||||
return (+new Date()) - start
|
||||
}
|
||||
|
||||
dig.start = async function (lightState: number[]) {
|
||||
try {
|
||||
await dig.ffmpeg.clearAll()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
try {
|
||||
await dig.ffmpeg.frame(dig.state, lightState)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
dig.display.start(dig.state.frame)
|
||||
await delay(20)
|
||||
}
|
||||
|
||||
dig.end = async function () {
|
||||
await delay(20)
|
||||
dig.display.end()
|
||||
}
|
||||
|
||||
module.exports = (display : any, ffmpeg : any, ffprobe : any) => {
|
||||
dig.display = display;
|
||||
dig.ffmpeg = ffmpeg;
|
||||
dig.ffprobe = ffprobe;
|
||||
return dig;
|
||||
}
|
Loading…
Reference in New Issue