Return the current value of the interrupt which is based on the type of interrupt.
The name of the digital interrupt.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Get the number of times this DigitalInterrupt has been interrupted with a tick.
const count = await board.getDigitalInterruptValue(
'my_example_digital_interrupt'
);
For more information, see Board API.
Get the high/low state of the given pin.
The pin number.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Get if it is true or false that the state of the pin is high.
const high = await board.getGPIO('15');
For more information, see Board API.
Get the duty cycle of the given pin of a board.
The pin number.
Optional
extra: StructThe duty cycle, which is a value from 0 to 1.
const board = new VIAM.BoardClient(machine, 'my_board');
// Get the duty cycle of this pin.
const dutyCycle = await board.getPWM('15');
For more information, see Board API.
Get the PWM frequency of the given pin of a board.
The pin.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Get the PWM frequency of this pin.
const freq = await board.getPWMFrequency('15');
For more information, see Board API.
Read the current value of an analog reader of a board.
The name of the analog reader.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Get the value of the analog signal "my_example_analog_reader" has most
// recently measured.
const reading = await board.readAnalogReader(
'my_example_analog_reader'
);
For more information, see Board API.
Set the high/low state of the given pin of a board.
The pin number.
When true, set the given pin to high. When false, set the given pin to low.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Set the pin to high.
await board.setGPIO('15', true);
For more information, see Board API.
Set power mode of the board.
const board = new VIAM.BoardClient(machine, 'my_board');
// Set the power mode of the board to OFFLINE_DEEP.
const duration = new VIAM.Duration({ seconds: 10n });
await board.setPowerMode(VIAM.PowerMode.OFFLINE_DEEP, duration);
For more information, see Board API.
Set the duty cycle of the given pin of a board.
The pin.
A value from 0 to 1.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Set the duty cycle to 0.6, meaning that this pin will be in the high state for
// 60% of the duration of the PWM interval period.
await board.setPWM('15', 0.6);
For more information, see Board API.
Set the PWM frequency of the given pin of a board.
The pin.
The PWM frequency, in hertz. 0 will use the board's default PWM frequency.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Set the PWM frequency of this pin to 1600 Hz.
await board.setPWMFrequency('15', 1600);
For more information, see Board API.
Stream digital interrupt ticks on the board.
const board = new VIAM.BoardClient(machine, 'my_board');
// Stream ticks from pins 8 and 11.
const ticks = await board.streamTicks(['8', '11']);
for await (const tick of ticks) {
console.log(
`Pin ${tick.pinName} changed to ${tick.high ? 'high' : 'low'} at ${tick.time}`
);
}
For more information, see Board API.
Write an analog value to a pin on the board.
The pin name.
An integer value to write.
Optional
extra: Structconst board = new VIAM.BoardClient(machine, 'my_board');
// Write the value 42 to "my_example_analog_writer".
await board.writeAnalog('my_example_analog_writer', 42);
For more information, see Board API.
Represents a physical general purpose compute board that contains various components such as analog readers, and digital interrupts.