From 4181c22995d0964f8ad9d002148076b83297198b Mon Sep 17 00:00:00 2001 From: mattmcw Date: Fri, 19 Jan 2024 06:49:03 -0500 Subject: [PATCH] Cleanup whitespace/semicolons and add concept for passing an exposure length to the image in millis. --- app/data/cfg.json | 3 ++- app/display.html | 36 ++++++++++++++++++++++++++++-------- app/lib/exec/index.d.ts | 12 ------------ processing/mcopy/cfg.json | 3 ++- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/app/data/cfg.json b/app/data/cfg.json index a8c271d..b4a3495 100644 --- a/app/data/cfg.json +++ b/app/data/cfg.json @@ -190,7 +190,8 @@ "error": "E", "camera_exposure": "G", "state": "H", - "home": "I" + "home": "I", + "offset": "O" } } } diff --git a/app/display.html b/app/display.html index 512d99b..639d5e2 100644 --- a/app/display.html +++ b/app/display.html @@ -59,6 +59,11 @@ const { ipcRenderer } = require('electron') const remote = require('@electron/remote') let imgTmp; + function delay (ms) { + return new Promise((resolve) => { + return setTimeout(resolve, ms) + }) + } async function setImage (src) { return new Promise(async (resolve, reject) => { imgTmp = new Image() @@ -67,11 +72,18 @@ body.className = '' body.classList.add('image') imgTmp.onload = function () { - img.style.backgroundImage = `url('${src}')`; - return resolve(src); - }; - imgTmp.src = src; - }); + img.style.backgroundImage = `url('${src}')` + return resolve(src) + } + imgTmp.src = src + }) + } + + function setBlank () { + let img = document.getElementById('img') + img.style.background = '' + img.style.backgroundUrl = '' + img.style.backgroundColor = 'black' } async function onMeter () { console.log('meter') @@ -134,7 +146,7 @@ const dpr = window.devicePixelRatio || 1 const screen = window.outerWidth / window.outerHeight const body = document.querySelector('body') - let ctx; + let ctx body.className = '' if (!can.classList.contains('show')) { can.classList.add('show') @@ -144,7 +156,7 @@ can.width = (window.innerHeight * arg.ratio) * dpr can.height = window.innerHeight * dpr } else { - can.width =window.innerWidth * dpr + can.width = window.innerWidth * dpr can.height = (window.innerWidth / arg.ratio) * dpr } } else { @@ -221,12 +233,20 @@ } async function onDigital (event, arg) { if (arg.src) { + if (arg.exposure) { + setBlank() + await delay(10) + } try { await setImage(arg.src) } catch (err) { console.error(err) } - ipcRenderer.send('display_load', { src : arg.src }); + if (arg.exposure) { + await delay(arg.exposure) + setBlank() + } + ipcRenderer.send('display_load', { src : arg.src }) } return event.returnValue = true } diff --git a/app/lib/exec/index.d.ts b/app/lib/exec/index.d.ts index 001b960..b20194c 100644 --- a/app/lib/exec/index.d.ts +++ b/app/lib/exec/index.d.ts @@ -1,13 +1 @@ declare const execRaw: any; -/** - * Promisified child_process.exec - * - * @param cmd - * @param arg - * @param opts See child_process.exec node docs - * @param {stream.Writable} opts.stdout If defined, child process stdout will be piped to it. - * @param {stream.Writable} opts.stderr If defined, child process stderr will be piped to it. - * - * @returns {Promise<{ stdout: string, stderr: stderr }>} - */ -declare function exec(...args: string[]): Promise; diff --git a/processing/mcopy/cfg.json b/processing/mcopy/cfg.json index a8c271d..b4a3495 100644 --- a/processing/mcopy/cfg.json +++ b/processing/mcopy/cfg.json @@ -190,7 +190,8 @@ "error": "E", "camera_exposure": "G", "state": "H", - "home": "I" + "home": "I", + "offset": "O" } } }