Cleanup whitespace/semicolons and add concept for passing an exposure length to the image in millis.
This commit is contained in:
parent
d31ac53bd1
commit
4181c22995
|
@ -190,7 +190,8 @@
|
|||
"error": "E",
|
||||
"camera_exposure": "G",
|
||||
"state": "H",
|
||||
"home": "I"
|
||||
"home": "I",
|
||||
"offset": "O"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<unknown>;
|
||||
|
|
|
@ -190,7 +190,8 @@
|
|||
"error": "E",
|
||||
"camera_exposure": "G",
|
||||
"state": "H",
|
||||
"home": "I"
|
||||
"home": "I",
|
||||
"offset": "O"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue