buttons - Push Buttons

The buttons module allows you to use card10’s push buttons as input in your scripts.

Example:

import buttons

print("Press bottom left or right button:")

while True:
   pressed = buttons.read(
       buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT
   )

   if pressed != 0:
      break

if pressed & buttons.BOTTOM_LEFT != 0:
   print("Left button pressed!")

if pressed & buttons.BOTTOM_RIGHT != 0:
   print("Right button pressed!")
buttons.read(mask)

Read button status.

Parameters

mask (int) – Mask of buttons to check. Create the mask by ORing buttons.BOTTOM_LEFT, buttons.BOTTOM_RIGHT, buttons.TOP_RIGHT, and buttons.TOP_LEFT (= buttons.RESET).

Returns

An integer with the bits for pressed buttons set. Use the same costants as for the mask to check which buttons were pressed.

buttons.BOTTOM_LEFT

Bottom left button.

buttons.BOTTOM_RIGHT

Bottom right button.

buttons.TOP_RIGHT

Top right button.

buttons.TOP_LEFT

Top left button (Reset button).

buttons.RESET

Top left button (Reset button).