BBR Button Board Documentation

Serial command reference#

The board’s configuration channel is a plain text serial port. The config app, the Python library or a serial terminal such as PuTTY can drive it.

  • You send one command per line, ending in a newline.
  • The board answers with one JSON object per line.
  • Every command produces exactly one final line, either {"ok":true,...} or {"ok":false,"err":"..."}.
  • The board may send event lines at any time, marked with "ev". One can arrive between a command and its reply.

Baud rate is ignored; any setting works.

Enter must send a newline, not a carriage return. PuTTY’s default sends CR, which this channel ignores: commands appear to be accepted and nothing happens. Set it to send LF, or use bbctl.

The commands#

Command What it does
hello Identify the board: firmware, serial, tile count, USB mode (usb now, usbSaved after the next replug)
tiles Every tile the board knows about
stats Uptime, poll cycle time, fault state, power budget
usb frc | xinput | desk | midi | sim Set the USB mode, applied at the next reset once saved. desk, midi and sim need firmware 0.4.0; an older board answers args. See USB modes
pixel on | pixel off Flash the main module’s light white on every button press. On by default; save keeps the setting
bind <btn> Wait for a key press and bind it to that button
bind <btn> add Same, but add to the button’s group instead of replacing
bind cancel Stop waiting
unbind <btn> Remove every key from a button
unbind <btn> <addr> <key> Remove one key from a group
bind axis <n> Bind axis 1–8 to the next encoder turned. frc reports axes 1–4; 5–8 move only in sim
unbind axis <n> Remove it
enc zero [<n>] Zero one encoder axis, or all of them
map get The whole configuration as JSON
map set <json> Replace it
save Write configuration to flash and verify it
led <btn> <rgb> [fx] [press] Live colour for a logical button
led tile <addr> <led> <rgb> [fx] Live colour by tile and LED number
led all <rgb> Every LED. led all off is the panic button
led reset Discard the live layer; back to saved defaults
power budget <mA> Set the LED power budget
test walk [ms] Press buttons 1→32 in turn, with no tile involved
test hold <btn> Hold one button
test all Every button at once
test off Stop

The test patterns are refused in desk and midi ({"ok":false,"err":"usb"}), as they would press every shortcut or play every note at once. test off always works.

Command What it does
disp <addr> … Write text, a bar or a picture to a display tile
disp <addr> slot <n> … Store, show, erase, check (info) or read back (read) one of the tile’s saved pictures
disp <addr> slot <n> rect <x> <y> <w> <h> Put part of a saved picture back on the panel
disp <addr> draw line\|poly\|fill <rgb565> <hex> Draw lines or filled rectangles: a colour as four hex digits, then the coordinates as hex bytes
disp <addr> draw text <fg> <bg> <x> <y> <text…> Draw text at a pixel position
replace <old> <new> Move a tile’s bindings to another address by hand
reset Reboot
reset factory Erase the configuration and reboot
boot Reboot into the USB bootloader for a firmware update

rgb is six hex digits or off. fx is solid, blink, fast or breathe. Addresses are 1–31, logical buttons 1–32, keys count from 0.

Events#

Event When
tile A tile went online, was lost, was assigned an address, or entered its bootloader
fault The fault indicator changed, with the reason. In desk, stuck means a key held for over 60 s was released
key A key was pressed — only while waiting for a binding
enc An encoder was turned — only while waiting for a binding
progress During a tile firmware update
player The FTC Driver Station assigned this board a player number
rumble A rumble packet arrived, with the legend code it decodes to — FTC mode only
lock The computer changed its Caps, Num or Scroll Lock light: {"ev":"lock","num":false,"caps":true,"scroll":false} — desk only
midi The computer sent the board a MIDI message, in hex: {"ev":"midi","data":"903C7F"} — midi only

A client that only wants request and response can ignore every line containing "ev".

A worked example#

> hello
< {"ok":true,"product":"Button Board","fw":"0.1.0","proto":1,"tiles":3,"mode":"run","usb":"frc"}
> bind 7
< {"ev":"key","addr":1,"key":4}
< {"ok":true,"btn":7,"addr":1,"key":4,"sources":1}
> led 7 FF8800 blink
< {"ok":true}
> save
< {"ok":true,"saved":true}

bbctl#

bbctl is a console for this channel. It comes with the Python library (pip install bbr-buttonboard, see Install the library). It sends the right newline endings, holds the port open so test mode survives, and reads past event lines to the reply.

bbctl                          # interactive console
bbctl hello stats              # run and exit
bbctl -p COM7 "test walk 250"  # explicit port