Skip to content

Commit

Permalink
add switch docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed May 10, 2023
1 parent 57984ec commit 9ac7615
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/sampleprj/src/mainswitch.ts
@@ -0,0 +1,6 @@
import { gpio } from "@devicescript/core"
import { startSwitch } from "@devicescript/servers"

const switch_ = startSwitch({
pin: gpio(2),
})
2 changes: 1 addition & 1 deletion vscode/src/server-info.json
Expand Up @@ -293,7 +293,7 @@
"imports": {
"startBME680": "@devicescript/drivers"
},
"snippet": "const { temperature, humidity, pressure, aqi } = await startBME680()\n"
"snippet": "const { temperature, humidity, pressure, airQualityIndex } = await startBME680()\n"
}
]
}
30 changes: 30 additions & 0 deletions website/docs/api/servers/switch.md
@@ -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.

0 comments on commit 9ac7615

Please sign in to comment.