TrafficLight
caution
This service is rc and may change in the future.
Controls a mini traffic with a red, orange and green LED.
import { TrafficLight } from "@devicescript/core"
const trafficLight = new TrafficLight()
Registers
red
The on/off state of the red light.
type:
Register<boolean>
(packing formatu8
)read and write
import { TrafficLight } from "@devicescript/core"
const trafficLight = new TrafficLight()
// ...
const value = await trafficLight.red.read()
await trafficLight.red.write(value)
- track incoming values
import { TrafficLight } from "@devicescript/core"
const trafficLight = new TrafficLight()
// ...
trafficLight.red.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.
yellow
The on/off state of the yellow light.
type:
Register<boolean>
(packing formatu8
)read and write
import { TrafficLight } from "@devicescript/core"
const trafficLight = new TrafficLight()
// ...
const value = await trafficLight.yellow.read()
await trafficLight.yellow.write(value)
- track incoming values
import { TrafficLight } from "@devicescript/core"
const trafficLight = new TrafficLight()
// ...
trafficLight.yellow.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.
green
The on/off state of the green light.
type:
Register<boolean>
(packing formatu8
)read and write
import { TrafficLight } from "@devicescript/core"
const trafficLight = new TrafficLight()
// ...
const value = await trafficLight.green.read()
await trafficLight.green.write(value)
- track incoming values
import { TrafficLight } from "@devicescript/core"
const trafficLight = new TrafficLight()
// ...
trafficLight.green.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.