brian.buttons.UiEventsListener
- UiEventsListener
UiEventsListener class objects
Collects button and knob events, so a program polling in a loop does not miss presses that happen between polls.
KnobEvent class objects
Knob events since the last knob_event_since_last() call.
turn_delta
Turn indents since the last call; positive is clockwise
turned_to
Absolute turn indent count since this listener was created
is_pressed
True if the knob is pressed
just_pressed
True if the knob was pressed since the last call
just_released
True if the knob was released since the last call
ButtonEvent class objects
Events of one button since the last buttons_event_since_last() call.
is_pressed
True if the button is pressed
just_pressed
True if the button was pressed since the last call
just_released
True if the button was released since the last call
ButtonsEvent class objects
Events of all buttons since the last buttons_event_since_last() call.
top_left
Top left button
top_right
Top right button
bottom_left
Bottom left button
bottom_right
Bottom right button
any_button
Any of the four corner buttons (knob excluded)
any_button_incl_knob
Any of the four corner buttons or the knob press
Button class objects
A button seen through this listener.
is_pressed
Returns:
True if the button is currently pressed (live state, does not consume events).
last_button_event
Returns:
Snapshot of the last event of this button, without resetting the just_pressed / just_released flags.
set_led
Sets desired effect and color for the LED of this button. These settings override the effect
requested by the OS, unless LedEffect.inherit is used. For any_button and any_button_incl_knob
all respective buttons change color/effect.
Arguments:
effect: Target LED effect.color: Target color. When unfilled default color from settings is used.
wait_for_press
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:
success: - True: If the desired button event was caught.
- False: If the timeout ran out.
wait_for_release
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:
success: - True: If the desired button event was caught.
- False: If the timeout ran out.
wait_for_press_and_release
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:
success: - True: If the desired button event was caught.
- False: If the timeout ran out.
Knob class objects
The knob seen through this listener.
turned_to
Returns:
Absolute turn indent count since this listener was created (live state, does not consume events).
last_button_event
Returns:
Snapshot of the last event of the knob, without resetting the just_pressed / just_released and turn_delta fields.
wait_for_directional_turn
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:
success: - True: If the desired button event was caught.
- False: If the timeout ran out.
wait_for_any_turn
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:
success: - True: If the desired button event was caught.
- False: If the timeout ran out.
top_left
Top left button
top_right
Top right button
bottom_left
Bottom left button
bottom_right
Bottom right button
any_button
Any of the four corner buttons (knob excluded)
any_button_incl_knob
Any of the four corner buttons or the knob press
knob
The knob
__init__
knob_event_since_last
This function will reset just_pressed, just_released fields and turn_delta fields.
Returns:
KnobEvent class of events that happened since last call.