Skip to content

Commit

Permalink
Fix DMX interval so it can vary
Browse files Browse the repository at this point in the history
  • Loading branch information
spensbot committed Dec 11, 2023
1 parent 96338f3 commit b63c37e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/main/engine/connections/dmx/DmxConnectionUsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/overlays/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Devices({}: Props) {
{
<DraggableNumber
value={deviceSetup.connectionSettings.openDmxRefreshRateHz}
min={10}
min={5}
max={40}
onChange={(newVal) =>
dispatch(setOpenDmxRefreshRateHz(newVal))
Expand Down

0 comments on commit b63c37e

Please sign in to comment.