fusion_hat.user_button module
- class fusion_hat.user_button.UserButton[source]
Bases:
objectUser button class using evdev for Linux input events
- set_on_click(callback: Callable[[], None]) → None[source]
Set the callback function when the user button is clicked
- Parameters:
callback (Callable[[], None]) – callback function
- set_on_press(callback: Callable[[], None]) → None[source]
Set the callback function when the user button is pressed
- Parameters:
callback (Callable[[], None]) – callback function
- set_on_release(callback: Callable[[], None]) → None[source]
Set the callback function when the user button is released
- Parameters:
callback (Callable[[], None]) – callback function
- set_on_press_released(callback: Callable[[], None]) → None[source]
Set the callback function when the user button is pressed and released
- Parameters:
callback (Callable[[], None]) – callback function
- set_on_long_press(callback: Callable[[], None], duration: float = 2.0) → None[source]
[Deprecated] Set the callback function when the user button is pressed for a long time
- Parameters:
callback (Callable[[], None]) – callback function
- set_on_long_press_released(callback: Callable[[], None], duration: float = 2.0) → None[source]
[Deprecated] Set the callback function when the user button is pressed for a long time and released
- Parameters:
callback (Callable[[], None]) – callback function
duration (float, optional) – long press duration(2.0~5.0)
- get_state() → bool[source]
Get the state of the user button
- Returns:
True if pressed, False if released
- Return type:
bool
- is_pressed() → bool[source]
Check if the user button is pressed
- Returns:
True if pressed, False if released
- Return type:
bool