spikedev.button

A module to interact with the left, right, center and connect buttons on the SPIKE hub

Example

from spikedev.button import ButtonCenter

button = ButtonCenter()
button.wait_for_bump()
print("center button was bumped")

Classes

class spikedev.button.Button(button_name, desc=None)

Bases: object

A base class for SPIKE buttons. button_name must be one of left, right, center or connect. desc is an optional string that will be using when printing a Button object.

is_pressed()

Return True if the button is currently pressed, else return False

was_pressed()

Return True if the button was pressed since the device started or the last time this method was called, else return False

presses()

Return an int of the number of button presses. Also resets this counter to zero.

is_released()

Return True if the button is currently released, else return False

wait_for_pressed(timeout_ms=None)

Wait timeout_ms for the button to be pressed. Return True if the button was pressed within timeout_ms, else return False. If timeout_ms is None this will wait for forever.

wait_for_released(timeout_ms=None)

Wait timeout_ms for the button to be released. Return True if the button was released within timeout_ms, else return False. If timeout_ms is None this will wait for forever.

wait_for_bump(timeout_ms=None)

Wait timeout_ms for the button to be bumped. Return True if the button was bumped within timeout_ms, else return False. If timeout_ms is None this will wait for forever.

class spikedev.button.ButtonLeft(desc=None)

Bases: spikedev.button.Button

class spikedev.button.ButtonRight(desc=None)

Bases: spikedev.button.Button

class spikedev.button.ButtonCenter(desc=None)

Bases: spikedev.button.Button

class spikedev.button.ButtonConnect(desc=None)

Bases: spikedev.button.Button