obniz to be used
Optional onchangeWhen the switch state changes, this callback function will be called. If you press and release a switch, it callbacks twice ("push" and "none").
// Javascript Example
obniz.display.clear();
obniz.switch.onchange = function(state) {
if (state === "push") {
obniz.display.print("Pushing");
} else {
obniz.display.clear();
}
}
current switch state
Rsponse waiting timeout in milliseconds
Static prefixedOptional context: anyOptional fn: ListenerFnOptional context: anyOptional once: booleanAdd a listener for a given event.
Optional context: anyAdd a one-time listener for a given event.
Optional context: anyRemove all listeners, or those of the specified event.
Optional event: stringRemove the listeners of a given event.
Optional fn: ListenerFnOptional context: anyOptional once: booleanWith this you wait until the switch status changes to state.
// Javascript Example
await obniz.switch.stateWait("push");
console.log("switch pushed");
await obniz.switch.stateWait("left");
console.log("switch left");
await obniz.switch.stateWait("right");
console.log("switch right");
await obniz.switch.stateWait("none");
console.log("switch none");
state for wait
Generated using TypeDoc
The embedded switch on obniz Board.