Skip to content

Commit

Permalink
updated sample
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 25, 2023
1 parent 6b0f258 commit 5dde23b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions website/docs/samples/weather-dashboard.mdx
Expand Up @@ -47,3 +47,35 @@ setInterval(async () => {
// highlight-end
}, 1000)
```


## Xiao + Expansion board + BME680

The generic sample above can be specialized to run on a Xiao ESP32-C3 with expansion board.

```ts
import {
XiaoExpansionBoard,
startCharacterScreen,
startBME680,
} from "@devicescript/drivers"
import { ValueDashboard } from "@devicescript/runtime"

const board = new XiaoExpansionBoard()
const { temperature, humidity } = await startBME680({
address: 0x76
})
const display = await board.startDisplay()
const screen = await startCharacterScreen(display)

const dashboard = new ValueDashboard(screen, {
temperature: { digits: 1, unit: "C" },
humi: { digits: 0, unit: "%" },
})

setInterval(async () => {
dashboard.values.temperature = await temperature.reading.read()
dashboard.values.humi = await humidity.reading.read()
await dashboard.show()
}, 1000)
```

0 comments on commit 5dde23b

Please sign in to comment.