Board API | Component APIs
Board API
The board API allows you to give commands to your board components for setting GPIO pins to high or low, setting PWM, and working with analog and digital interrupts.
The board component supports the following methods:
| Method Name | Description | viam-micro-server Support |
|---|---|---|
SetGPIO |
Set the digital signal output of this pin to low (0V) or high (active, >0V). | |
GetGPIO |
Get if the digital signal output of this pin is high (active, >0V). | |
GetPWM |
Get the pin’s pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] representing the percentage of time the digital signal output by this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency). |
|
SetPWM |
Set the pin’s Pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] indicating the percentage of time the digital signal output of this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency). |
|
PWMFrequency |
Get the PWM frequency of the GPIO pin. | |
SetPWMFrequency |
Set the pin to the given PWM frequency (in Hz). When frequency is 0, it will use the board’s default PWM frequency. |
|
GetDigitalInterruptValue |
Get the current value of a configured digital interrupt. | |
ReadAnalogReader |
Read the current integer value of the digital signal output by the ADC. | |
WriteAnalog |
Write an analog value to a pin on the board. | |
StreamTicks |
Start a stream of DigitalInterrupt ticks. |
|
SetPowerMode |
Set the board to the indicated PowerMode. |
|
AnalogByName |
Get a configured Analog by name. |
|
DigitalInterruptByName |
Get a DigitalInterrupt by name. |
|
GPIOPinByName |
Get a GPIOPin by pin number. |
|
GetGeometries |
Get all the geometries associated with the board in its current configuration, in the frame of the board. | |
Reconfigure |
Reconfigure this resource. | |
DoCommand |
Execute model-specific commands that are not otherwise defined by the component API. | |
GetResourceName |
Get the ResourceName for this board. |
|
Close |
Safely shut down the resource and prevent further use. |
API
SetGPIO
Set the digital signal output of this pin to low (0V) or high (active, >0V).
Supported by viam-micro-server.
Parameters:
high( bool) (required): When true, sets the pin to high. When false, sets the pin to low.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
Example:
For more information, see the Python SDK Docs.
GetGPIO
Get if the digital signal output of this pin is high (active, >0V).
Supported by viam-micro-server.
Parameters:
extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- ( bool): : Indicates if the state of the pin is high.
GetPWM
Get the pin’s pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] representing the percentage of time the digital signal output by this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency).
Supported by viam-micro-server.
Parameters:
Returns:
- ( float): : The duty cycle.
SetPWM
Set the pin’s Pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] indicating the percentage of time the digital signal output of this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency).
Supported by viam-micro-server.
Parameters:
duty_cycle( float) (required): The duty cycle.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
PWMFrequency
Get the PWM frequency of the GPIO pin.
Supported by viam-micro-server.
Parameters:
Returns:
- ( int): : The PWM frequency.
SetPWMFrequency
Set the pin to the given PWM frequency (in Hz). When frequency is 0, it will use the board’s default PWM frequency.
GetDigitalInterruptValue
Get the current value of a configured digital interrupt. The value is the number of times the interrupt has been interrupted with a tick.
ReadAnalogReader
Read the current integer value of the digital signal output by the ADC.
WriteAnalog
Write an analog value to a pin on the board.
StreamTicks
Start a stream of DigitalInterrupt ticks.
SetPowerMode
Set the board to the indicated PowerMode.
AnalogByName
Get a configured Analog by name.
DigitalInterruptByName
Get a DigitalInterrupt by name.
GPIOPinByName
Get a GPIOPin by pin number.
GetGeometries
Get all the geometries associated with the board in its current configuration, in the frame of the board.
Reconfigure
Reconfigure this resource.
DoCommand
Execute model-specific commands that are not otherwise defined by the component API.
GetResourceName
Get the ResourceName for this board.
Close
Safely shut down the resource and prevent further use.