Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dba3ce0

Browse filesBrowse files
committed
test server docs
1 parent 054cd29 commit dba3ce0
Copy full SHA for dba3ce0

3 files changed

+25-3Lines changed: 25 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎website/docs/api/servers/analog.md‎

Copy file name to clipboardExpand all lines: website/docs/api/servers/analog.md
+4-2Lines changed: 4 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ In the simplest case, you just pass the pin to `startPotentiometer()`.
1515
The voltage on the pin (typically between 0V (GND) and 3.3V (VCC)) will be translated to a number between 0 and 1.
1616

1717
```ts
18+
import { gpio } from "@devicescript/core"
1819
import { startPotentiometer } from "@devicescript/servers"
1920

2021
const slider = startPotentiometer({
2122
pin: ds.gpio(3),
2223
})
23-
const v = await slider.position.read()
24-
console.log(`val: ${v * 100}%`)
24+
slider.subscribe(v => console.data({ value: 100 * v}))
2525
```
2626

2727
## Scaling
@@ -35,6 +35,7 @@ The defaults are `{ offset: 0, scale: 1024 }` so the `raw_reading` is just repor
3535
For example, if you find you can never quite reach the `0` and `1` values, you can try the following:
3636

3737
```ts
38+
import { gpio } from "@devicescript/core"
3839
import { startPotentiometer } from "@devicescript/servers"
3940

4041
const slider = startPotentiometer({
@@ -55,6 +56,7 @@ regardless if you measure it or not.
5556
To improve power consumption, you may connect say R to a GPIO and configure the service like this:
5657

5758
```ts
59+
import { gpio } from "@devicescript/core"
5860
import { startPotentiometer } from "@devicescript/servers"
5961

6062
const slider = startPotentiometer({
Collapse file
+20Lines changed: 20 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: Mounts a potentiometer
3+
title: Potentiometer
4+
---
5+
6+
# Potentiometer
7+
8+
The `startPotentiometer` starts a simple analog sensor server that models a potentiometer.
9+
10+
- Please refer to the **[analog documentation](./analog)** for details.
11+
12+
```ts
13+
import { gpio } from "@devicescript/core"
14+
import { startPotentiometer } from "@devicescript/servers"
15+
16+
const slider = startPotentiometer({
17+
pin: ds.gpio(3),
18+
})
19+
slider.subscribe(v => console.data({ value: 100 * v }))
20+
```

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.