Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { gpio } from "@devicescript/core" | ||
import { startSwitch } from "@devicescript/servers" | ||
|
||
const switch_ = startSwitch({ | ||
pin: gpio(2), | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
description: Mounts a switch server | ||
title: Switch | ||
--- | ||
|
||
# Switch | ||
|
||
The `startSwitch` function starts a [switch](https://microsoft.github.io/jacdac-docs/services/switch) server on the device | ||
and returns a [client](/api/clients/switch). | ||
|
||
```ts | ||
import { gpio } from "@devicescript/core" | ||
import { startSwitch } from "@devicescript/servers" | ||
|
||
const switch = startSwitch({ | ||
pin: gpio(2), | ||
}) | ||
``` | ||
|
||
The [service instance name](https://microsoft.github.io/jacdac-docs/services/_base/) is automatically set to the variable name. In this example, it is set to `switch`. | ||
|
||
## Options | ||
|
||
### pin | ||
|
||
The pin hardware identifier on which to mount the relay. | ||
|
||
### options | ||
|
||
Other configuration options are available in the options parameter. |