-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from the-orange-alliance/jan-app
Jan app
- Loading branch information
Showing
6 changed files
with
442 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
import { WledInitParameters, WledUpdateParameters } from "@toa-lib/models"; | ||
import { workerData, parentPort } from 'worker_threads' | ||
import { WledController } from "./WLEDController.js"; | ||
import { WledInitParameters, WledUpdateParameters } from '@toa-lib/models'; | ||
import { workerData, parentPort } from 'worker_threads'; | ||
import { WledController } from './WLEDController.js'; | ||
|
||
interface UpdateMessage { | ||
data: WledUpdateParameters | ||
type: "update" | ||
data: WledUpdateParameters; | ||
type: 'update'; | ||
} | ||
|
||
interface InitializeMessage { | ||
type: "initialize" | ||
data: WledInitParameters | ||
type: 'initialize'; | ||
data: WledInitParameters; | ||
} | ||
|
||
type Message = UpdateMessage | InitializeMessage | ||
type Message = UpdateMessage | InitializeMessage; | ||
|
||
const wled = new WledController(workerData) | ||
wled.initialize() | ||
const wled = new WledController(workerData); | ||
wled.initialize(); | ||
|
||
wled.eventEmitter.on('status', (status) => { | ||
if (parentPort) { | ||
parentPort?.postMessage({ type: 'status', data: status }); | ||
} | ||
}); | ||
|
||
if (parentPort) { | ||
parentPort.on('message', (message: Message) => { | ||
if (message.type === "update") { | ||
wled.update(message.data) | ||
} else if (message.type === "initialize") { | ||
wled.initialize(message.data) | ||
} | ||
}); | ||
parentPort.on('message', (message: Message) => { | ||
if (message.type === 'update') { | ||
wled.update(message.data); | ||
} else if (message.type === 'initialize') { | ||
wled.initialize(message.data); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.