You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
invert_axes=["y", "z", "roll", "yaw"], # Invert these
196
196
)
197
197
198
-
with pyspacemouse.open(device_spec=custom) as device:
198
+
with pyspacemouse.open(device_spec=custom, nonblocking=False) as device:
199
199
state = device.read()
200
200
```
201
201
202
202
See [Custom Device Configuration](./docs/mouseApi/index.md#custom-device-configuration) for full API.
203
203
204
+
## Blocking, Non-Blocking, sleeps, and callbacks
205
+
206
+
The default `open()` function uses `nonblocking=True`, which means `read()` can return without any data if none is available.
207
+
However, the spacemouse device sends data very quickly and the operating system may buffer this data if it is not being read quickly enough.
208
+
This means that you are very unlikely to ever _not_ get data from `read()`, even in non-blocking mode.
209
+
This also means that if you have a loop that calls `read()` and it is slow, for example if you add `sleep(0.01)`, you might start to see the data start lagging behind a bit.
210
+
For instance, if you poke the spacemouse it will take a few dozen/hundred milliseconds for non-zero data to be return from `read()`.
211
+
This is why you see many of our examples us `nonblocking=False` and no sleep at all.
212
+
This is an attempt to read as quickly as possible to avoid buffering data.
213
+
If you want to minimize the effects of buffering while still operating at a lower rate, consider something like this:
0 commit comments