dexter-controller 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dexter-controller
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Dexter Controller for the HARP Load Cells
5
5
  Author: Hardware and Software Platform, Champalimaud Foundation
6
6
  Author-email: Hardware and Software Platform, Champalimaud Foundation <software@research.fchampalimaud.org>
@@ -1,21 +1,21 @@
1
- [project]
2
- name = "dexter-controller"
3
- version = "0.2.0"
4
- description = "Dexter Controller for the HARP Load Cells"
5
- readme = "README.md"
6
- authors = [
7
- { name = "Hardware and Software Platform, Champalimaud Foundation", email = "software@research.fchampalimaud.org" }
8
- ]
9
- requires-python = ">=3.10"
10
- dependencies = [
11
- "bleak==2.1.1",
12
- "harp-loadcells>=0.1.0a3",
13
- ]
14
-
15
- [project.urls]
16
- Repository = "https://github.com/fchampalimaud/dexter-controller/"
17
- "Bug Tracker" = "https://github.com/fchampalimaud/dexter-controller/issues"
18
-
19
- [build-system]
20
- requires = ["uv_build>=0.9.5,<0.10.0"]
21
- build-backend = "uv_build"
1
+ [project]
2
+ name = "dexter-controller"
3
+ version = "0.2.1"
4
+ description = "Dexter Controller for the HARP Load Cells"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Hardware and Software Platform, Champalimaud Foundation", email = "software@research.fchampalimaud.org" }
8
+ ]
9
+ requires-python = ">=3.10"
10
+ dependencies = [
11
+ "bleak==2.1.1",
12
+ "harp-loadcells>=0.1.0a3",
13
+ ]
14
+
15
+ [project.urls]
16
+ Repository = "https://github.com/fchampalimaud/dexter-controller/"
17
+ "Bug Tracker" = "https://github.com/fchampalimaud/dexter-controller/issues"
18
+
19
+ [build-system]
20
+ requires = ["uv_build>=0.9.5,<0.10.0"]
21
+ build-backend = "uv_build"
@@ -30,6 +30,7 @@ class BLELoadCellDevice:
30
30
  self.identifier = f"BLE:{DEVICE_NAME}"
31
31
  self._queue = deque()
32
32
  self._queue_lock = threading.Lock()
33
+ self._recent_timestamps = deque(maxlen=NUM_READINGS * 2)
33
34
 
34
35
  self._stop_event = threading.Event()
35
36
  self._ready_event = threading.Event()
@@ -81,6 +82,12 @@ class BLELoadCellDevice:
81
82
  for reading_index in range(NUM_READINGS):
82
83
  base = 4 + (reading_index * BLOCK_SIZE)
83
84
  timestamp_us = struct.unpack_from("<Q", data, base)[0]
85
+
86
+ if timestamp_us in self._recent_timestamps:
87
+ continue
88
+
89
+ self._recent_timestamps.append(timestamp_us)
90
+
84
91
  load_cells = list(struct.unpack_from(f"<{LOAD_CELLS}H", data, base + 8))
85
92
  self._queue.append(
86
93
  BLELoadCellEvent(
@@ -93,6 +100,7 @@ class BLELoadCellDevice:
93
100
  async def _run(self):
94
101
  print("Searching for BLE device...")
95
102
  device = await self._discover_target()
103
+ print(f"Found {self.identifier}")
96
104
  if not device:
97
105
  self._connection_error = RuntimeError("No matching BLE peripheral found")
98
106
  self._ready_event.set()
@@ -102,7 +110,7 @@ class BLELoadCellDevice:
102
110
  device,
103
111
  disconnected_callback=lambda _: self._stop_event.set(),
104
112
  )
105
-
113
+ print(f"Connecting to {self.identifier}")
106
114
  try:
107
115
  await self._client.connect()
108
116
  await self._client.start_notify(CHAR_UUID, self._notification_callback)