Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,10 @@ or the type of a parameter.
### wait_for_event

Blocks execution until a joystick event occurs, then returns an `InputEvent`
representing the event that occurred.
representing the event that occurred.

wait_for_event should not be used at the same time as direction_up, direction_left,
direction_right, direction_down, direction_middle or direction_any functions.

```python
from sense_hat import SenseHat
Expand Down Expand Up @@ -709,6 +712,9 @@ print("The joystick was {} {}".format(event.action, event.direction))
Returns a list of `InputEvent` tuples representing all events that have
occurred since the last call to `get_events` or `wait_for_event`.

get_events should not be used at the same time as direction_up, direction_left,
direction_right, direction_down, direction_middle or direction_any functions.

```python
from sense_hat import SenseHat

Expand All @@ -726,6 +732,8 @@ joystick is pushed in the associated direction (or in any direction in the case
of `direction_any`). The function assigned must either take no parameters or
must take a single parameter which will be passed the associated `InputEvent`.

These functions should not be used at the same time as wait_for_event or get_events.

```python
from sense_hat import SenseHat, ACTION_PRESSED, ACTION_HELD, ACTION_RELEASED
from signal import pause
Expand Down
3 changes: 3 additions & 0 deletions sense_hat/stick.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ def wait_for_event(self, emptybuffer=False):
events will be thrown away first. This is most useful if you are only
interested in "pressed" events.
"""
if self._callbacks:
raise RuntimeError('Cannot use wait_for_event when callbacks are assigned')

if emptybuffer:
while self._wait(0):
self._read()
Expand Down