Added lights to train controller
This commit is contained in:
parent
0a80e02406
commit
7a23697685
@ -25,7 +25,8 @@ const trains = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NK_Horizon_2",
|
name: "NK_Horizon_2",
|
||||||
ports: ["A"]
|
ports: ["A"],
|
||||||
|
lights: ["B"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -115,6 +116,11 @@ poweredUP.on("discover", async (hub) => {
|
|||||||
trainHub._hub = hub;
|
trainHub._hub = hub;
|
||||||
hub.setLEDColor(train.color);
|
hub.setLEDColor(train.color);
|
||||||
console.log(`Connected to ${train.name} (${hub.name})`);
|
console.log(`Connected to ${train.name} (${hub.name})`);
|
||||||
|
hub.on("attach", (port, type) => {
|
||||||
|
if (type === PoweredUP.Consts.Devices.LED_LIGHTS && trainHub.lights && trainHub.lights.indexOf(port) >= 0) {
|
||||||
|
hub.setLightBrightness(port, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
hub.on("disconnect", () => {
|
hub.on("disconnect", () => {
|
||||||
console.log(`Disconnected from ${train.name} (${hub.name})`);
|
console.log(`Disconnected from ${train.name} (${hub.name})`);
|
||||||
delete trainHub._hub;
|
delete trainHub._hub;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user