Skip to main content

CapacitiveButton

caution

This service is rc and may change in the future.

A configuration service for a capacitive push-button.

import { CapacitiveButton } from "@devicescript/core"

const capacitiveButton = new CapacitiveButton()

Commands

calibrate

Request to calibrate the capactive. When calibration is requested, the device expects that no object is touching the button. The report indicates the calibration is done.

capacitiveButton.calibrate(): Promise<void>

Registers

activeThreshold

Indicates the threshold for up events.

  • type: Register<number> (packing format u0.16)

  • read and write

import { CapacitiveButton } from "@devicescript/core"

const capacitiveButton = new CapacitiveButton()
// ...
const value = await capacitiveButton.activeThreshold.read()
await capacitiveButton.activeThreshold.write(value)
  • track incoming values
import { CapacitiveButton } from "@devicescript/core"

const capacitiveButton = new CapacitiveButton()
// ...
capacitiveButton.activeThreshold.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.