Skip to content

Commit 429feb4

Browse files
committed
fix(disconnection): Increased disconnection time condition
Increased the time it takes for a controller to be flagged as disconnected, from 100ms to 1500ms. This is to avoid mistakes in disconnection identification. The BLE connectivity sometimes showcases spikes in latency, which from the driver side can be mistaken for a controller disconnection state.
1 parent b4ecd63 commit 429feb4

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

etee/driver_eteecontroller.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ def __init__(self):
118118
:type: Event """
119119

120120
self.left_hand_lost = EteeControllerEvent()
121-
"""Event for losing left controller connection. Occurs when data is not received for more than 0.5 seconds.
121+
"""Event for losing left controller connection. Occurs when data is not received for more than 1.5 seconds.
122122
123123
:type: Event """
124124

125125
self.right_hand_lost = EteeControllerEvent()
126-
"""Event for losing right controller connection. Occurs when data is not received for more than 0.5 seconds.
126+
"""Event for losing right controller connection. Occurs when data is not received for more than 1.5 seconds.
127127
128128
:type: Event """
129129

130130
self.data_lost = EteeControllerEvent()
131-
"""Event for losing data from both controllers. Occurs when data is not received for more than 0.5 seconds.
131+
"""Event for losing data from both controllers. Occurs when data is not received for more than 1.5 seconds.
132132
133133
:type: Event """
134134

@@ -256,7 +256,6 @@ def _api_data_callback(self, frameno, data):
256256
:param dict data: Dictionary of the parsed controller data.
257257
"""
258258
if data["hand"] == 0:
259-
# print(time.time() - self.hand_last_on_left)
260259
self._api_data_left = data
261260
self._hand_last_on_left = time.time()
262261
self._frameno_left += 1
@@ -272,10 +271,10 @@ def _api_data_callback(self, frameno, data):
272271

273272
self.hand_received.emit()
274273

275-
if time.time() - self._hand_last_on_left > 0.1 and self._api_data_left is not None:
274+
if (time.time() - self._hand_last_on_left) > 1.5 and self._api_data_left is not None:
276275
self._api_data_left = None
277276
self.left_hand_lost.emit()
278-
if time.time() - self._hand_last_on_right > 0.1 and self._api_data_left is not None:
277+
if (time.time() - self._hand_last_on_right) > 1.5 and self._api_data_right is not None:
279278
self._api_data_right = None
280279
self.right_hand_lost.emit()
281280

@@ -314,8 +313,8 @@ def _rest_callback(self, reading):
314313
"""
315314
if reading is not None:
316315
return
317-
left_lost = time.time() - self._hand_last_on_left > 0.1 and self._api_data_left is not None
318-
right_lost = time.time() - self._hand_last_on_right > 0.1 and self._api_data_right is not None
316+
left_lost = (time.time() - self._hand_last_on_left) > 1.5 and self._api_data_left is not None
317+
right_lost = (time.time() - self._hand_last_on_right) > 1.5 and self._api_data_right is not None
319318
if left_lost:
320319
self._api_data_left = None
321320
self.left_hand_lost.emit()

0 commit comments

Comments
 (0)