Skip to content

Commit

Permalink
switch to bacon based interval
Browse files Browse the repository at this point in the history
  • Loading branch information
noahm committed Feb 21, 2025
1 parent 71fe6a6 commit 945216f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sdk/smx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class SMXStage {
private debug = true;
private _config: SMXConfig | null = null;
private panelTestMode = PanelTestMode.Off;
private testModeIntervalHandle: number | null = null;
private cancelTestModeInterval: Bacon.Unsub | null = null;

public get config() {
return this._config?.config || null;
Expand Down Expand Up @@ -243,9 +243,9 @@ export class SMXStage {
// We don't want to send the "Off" command multiple times, so only send it if
// it's currently activated
if (this.panelTestMode !== PanelTestMode.Off) {
if (this.testModeIntervalHandle !== null) {
clearInterval(this.testModeIntervalHandle);
this.testModeIntervalHandle = null;
if (this.cancelTestModeInterval) {
this.cancelTestModeInterval();
this.cancelTestModeInterval = null;
}
// Turn off panel test mode, and send "Off" event
this.panelTestMode = mode;
Expand Down Expand Up @@ -274,10 +274,10 @@ export class SMXStage {

// The Panel Test Mode command needs to be resent approximately every second, or else the stage will
// auto time out and turn off Panel Test Mode itself
this.testModeIntervalHandle = setInterval(() => {
this.cancelTestModeInterval = Bacon.interval(1000, null).subscribe(() => {
console.log("Test Mode Push Interval");
this.events.output$.push(Uint8Array.of(API_COMMAND.SET_PANEL_TEST_MODE, char2byte(" "), mode, char2byte("\n")));
}, 1000);
});
}
}

Expand Down

0 comments on commit 945216f

Please sign in to comment.