To preserve the light functionality, the light command needed to have its await statements re-organized. Issue was that light values issued to the firmware take the form of sending the character "l" and then the rgb value of the light "255,255,255" and so forth. Then the program responds with the "l" to confirm the end of the command. Because of the change within the arduino library, to treat the arduino.send() method as an async function, the program was locking up waiting for the "l" response before it could send the rgb value string.
This commit is contained in:
parent
f1ca18b4a5
commit
ce6e450b44
10
app/main.js
10
app/main.js
|
@ -371,7 +371,6 @@ light.init = function () {
|
||||||
}
|
}
|
||||||
light.listen = function () {
|
light.listen = function () {
|
||||||
ipcMain.on('light', async (event, arg) => {
|
ipcMain.on('light', async (event, arg) => {
|
||||||
//return new Promise(async(resolve, reject) => {
|
|
||||||
try {
|
try {
|
||||||
await light.set(arg.rgb, arg.id)
|
await light.set(arg.rgb, arg.id)
|
||||||
}catch (err) {
|
}catch (err) {
|
||||||
|
@ -379,25 +378,24 @@ light.listen = function () {
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
event.returnValue = true
|
event.returnValue = true
|
||||||
// return resolve(true)
|
|
||||||
//})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
light.set = async function (rgb, id) {
|
light.set = async function (rgb, id) {
|
||||||
const str = rgb.join(',');
|
const str = rgb.join(',');
|
||||||
let ms
|
let ms
|
||||||
try {
|
try {
|
||||||
ms = await arduino.send('light', mcopy.cfg.arduino.cmd.light)
|
ms = arduino.send('light', mcopy.cfg.arduino.cmd.light)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
console.log(ms)
|
await delay(1)
|
||||||
await delay(10)
|
|
||||||
try {
|
try {
|
||||||
arduino.string('light', str)
|
arduino.string('light', str)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
await delay(1)
|
||||||
|
await ms
|
||||||
return await light.end(rgb, id, ms)
|
return await light.end(rgb, id, ms)
|
||||||
}
|
}
|
||||||
light.end = async function (rgb, id, ms) {
|
light.end = async function (rgb, id, ms) {
|
||||||
|
|
Loading…
Reference in New Issue