Skip to main content

MatrixKeypad

caution

This service is experimental and may change in the future.

A matrix of buttons connected as a keypad

import { MatrixKeypad } from "@devicescript/core"

const matrixKeypad = new MatrixKeypad()

Registers

reading

The coordinate of the button currently pressed. Keys are zero-indexed from left to right, top to bottom: row = index / columns, column = index % columns.

  • type: Register<any[]> (packing format r: u8)

  • track incoming values

import { MatrixKeypad } from "@devicescript/core"

const matrixKeypad = new MatrixKeypad()
// ...
matrixKeypad.reading.subscribe(async (value) => {
...
})
note

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

rows

Number of rows in the matrix

  • type: Register<number> (packing format u8)

  • constant: the register value will not change (until the next reset)

  • read only

import { MatrixKeypad } from "@devicescript/core"

const matrixKeypad = new MatrixKeypad()
// ...
const value = await matrixKeypad.rows.read()
note

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

columns

Number of columns in the matrix

  • type: Register<number> (packing format u8)

  • constant: the register value will not change (until the next reset)

  • read only

import { MatrixKeypad } from "@devicescript/core"

const matrixKeypad = new MatrixKeypad()
// ...
const value = await matrixKeypad.columns.read()
note

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

labels

The characters printed on the keys if any, in indexing sequence.

  • type: Register<any[]> (packing format r: z)
  • optional: this register may not be implemented
  • constant: the register value will not change (until the next reset)
note

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

variant

The type of physical keypad. If the variant is ElastomerLEDPixel and the next service on the device is a LEDPixel service, it is considered as the service controlling the LED pixel on the keypad.

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { MatrixKeypad } from "@devicescript/core"

const matrixKeypad = new MatrixKeypad()
// ...
const value = await matrixKeypad.variant.read()
note

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

Events

down

Emitted when a key, at the given index, goes from inactive (pressed == 0) to active.

matrixKeypad.down.subscribe(() => {

})

up

Emitted when a key, at the given index, goes from active (pressed == 1) to inactive.

matrixKeypad.up.subscribe(() => {

})

click

Emitted together with up when the press time was not longer than 500ms.

matrixKeypad.click.subscribe(() => {

})

longClick

Emitted together with up when the press time was more than 500ms.

matrixKeypad.longClick.subscribe(() => {

})