Skip to content

brian.uicontrol.Btns

brian.uicontrol

BTNS class objects

class BTNS()

Static singleton providing access to the physical buttons and knob on the device via the global button state listener.

BTNS is not instantiable — it is a pre-existing module-level object. Button attributes like is_pressed and turned_to reflect the live hardware state.

Button class objects

class Button()

is_pressed

True if the button is currently pressed by the user.

wait_for_press

def wait_for_press(timeout_ms: Optional[int] = None) -> bool

Waits for next button press event. This function is blocking.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait. If the timeout is not provided or is None, the function will wait indefinitely.

Returns:

True if the desired button event was caught; False if the timeout ran out.

wait_for_release

def wait_for_release(timeout_ms: Optional[int] = None) -> bool

Waits for next button release event. This function is blocking.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait. If the timeout is not provided or is None, the function will wait indefinitely.

Returns:

True if the desired button event was caught; False if the timeout ran out.

wait_for_press_and_release

def wait_for_press_and_release(timeout_ms: Optional[int] = None) -> bool

Waits for next button press and release event. This function is blocking.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait. If the timeout is not provided or is None, the function will wait indefinitely.

Returns:

True if the desired button event was caught; False if the timeout ran out.

Knob class objects

class Knob(Button)

turned_to

Absolute turn indent count (offset-corrected). Can be reset via `reset_absolute_rotation()`.

wait_for_directional_turn

def wait_for_directional_turn(clockwise: bool = True, timeout_ms: Optional[int] = None) -> bool

Waits for next directional turn of the knob. This function is blocking.

Arguments:

  • clockwise: Whether to wait for clockwise or counterclockwise turn.
  • timeout_ms: Maximum number of milliseconds to wait. If the timeout is not provided or is None, the function will wait indefinitely.

Returns:

True if the desired button event was caught; False if the timeout ran out.

wait_for_any_turn

def wait_for_any_turn(timeout_ms: Optional[int] = None) -> bool

Waits for next any turn of the knob. This function is blocking.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait. If the timeout is not provided or is None, the function will wait indefinitely.

Returns:

True if the desired button event was caught; False if the timeout ran out.

reset_absolute_rotation

def reset_absolute_rotation(new_turned_to: int = 0) -> None

Resets turned_to back to zero (or the provided value).

Arguments:

  • new_turned_to: Value that turned_to should return immediately after this call. Defaults to 0.

BTNS fields

top_left

top_right

bottom_left

bottom_right

any

any_incl_knob

knob