hub.button
– Button¶
The button module provides access to all buttons on the hub.
Attributes¶
The left button.
The right button.
The center button.
The button with the Bluetooth symbol.
The Button class¶
Provides access to button state and callback.
Each of the buttons listed above are instances of this class. You cannot instantiate additional button objects.
Gets the state of the button.
- Returns
True
if it is pressed,False
otherwise.
Checks if this button was pressed since this method was last called.
- Returns
True
if it was pressed at least once since the previous call,False
otherwise.
Gets the number of times this button was pressed since this method was last called.
- Returns
The number of presses since the last call.
Sets the callback function that is called when the button is pressed and when it is released.
The function must accept one argument, whose value indicates why the callback was called:
If the value is
0
, the button is now pressed.Otherwise, the button is now released. The value represents how many milliseconds it was pressed before it was released.
- Parameters
function – Callable function that takes one argument. Choose
None
to disable the callback.