Install the library#
The Button Board can be driven from a program on the Driver Station laptop โ reading robot state from NetworkTables and pushing LED colours and display text back to the panel. bbr-buttonboard is the Python library for that.
You do not need this to use the board. Buttons work through the Driver Station with nothing installed. This is for making the panel react to the robot.
What you need#
- Python 3.9 or newer.
python3 -m pip install bbr-buttonboard
That brings pyserial with it, and puts the bbctl console on your PATH. Two extras add what some features need:
python3 -m pip install "bbr-buttonboard[pictures]" # Pillow, to load images onto display tiles
python3 -m pip install "bbr-buttonboard[networktables]" # pyntcore, to read robot state
The source is on GitHub at BuildingBlockRobotics/BBRButtonBoard, under the MIT licence.
Check it works#
from buttonboard import Board
with Board.open() as board: # finds the COM port by itself
print(board.hello())
{'ok': True, 'product': 'Button Board', 'fw': '0.1.0', 'proto': 1, ...}
If it cannot find the board, pass the port explicitly โ Board.open(port="COM7") on Windows, Board.open(port="/dev/ttyACM0") on Linux.
Without a board#
MockBoard lets you write and test a companion app with no hardware attached:
from buttonboard import MockBoard
board = MockBoard()
board.led(3, "red")
print(board.state.leds) # {('btn', 3): 'led 3 FF0000'}
One connection at a time#
Only one program can have the board open. If the config app has it open in a browser tab, your script cannot open it, and the other way round. Close one before starting the other.