From b63c37e7ab66c6b6a0d9c780b7f4c835ddf9ad9e Mon Sep 17 00:00:00 2001 From: spensbot Date: Mon, 11 Dec 2023 09:25:47 -0800 Subject: [PATCH] Fix DMX interval so it can vary --- src/main/engine/connections/dmx/DmxConnectionUsb.ts | 10 ++++------ src/renderer/overlays/Devices.tsx | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/engine/connections/dmx/DmxConnectionUsb.ts b/src/main/engine/connections/dmx/DmxConnectionUsb.ts index a31662c..1533beb 100644 --- a/src/main/engine/connections/dmx/DmxConnectionUsb.ts +++ b/src/main/engine/connections/dmx/DmxConnectionUsb.ts @@ -38,9 +38,7 @@ export class DmxConnectionUsb { this.config = configByDeviceType[device.type as DmxUsbDeviceType] this.lastHz = this.config.refreshHz(this.c) this.device.name = this.config.name - this.intervalHandle = setInterval(() => { - this.sendDmx() - }, 1000 / this.config.refreshHz(c)) + this.intervalHandle = this.beginInterval() } static async create( @@ -56,14 +54,14 @@ export class DmxConnectionUsb { return new DmxConnectionUsb(device, serialConnection, c) } - beginInterval() { - this.intervalHandle = setInterval(() => { + beginInterval(): NodeJS.Timer { + return setInterval(() => { this.sendDmx() const hz = this.config.refreshHz(this.c) if (this.lastHz !== hz) { this.lastHz = hz clearInterval(this.intervalHandle) - this.beginInterval() + this.intervalHandle = this.beginInterval() } }, 1000 / this.config.refreshHz(this.c)) } diff --git a/src/renderer/overlays/Devices.tsx b/src/renderer/overlays/Devices.tsx index 90e86da..3456956 100644 --- a/src/renderer/overlays/Devices.tsx +++ b/src/renderer/overlays/Devices.tsx @@ -69,7 +69,7 @@ export default function Devices({}: Props) { { dispatch(setOpenDmxRefreshRateHz(newVal))