flexitac 0.2.2__tar.gz → 0.3.0__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.
- {flexitac-0.2.2/flexitac.egg-info → flexitac-0.3.0}/PKG-INFO +1 -1
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/__init__.py +1 -1
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/sensor.py +23 -0
- {flexitac-0.2.2 → flexitac-0.3.0/flexitac.egg-info}/PKG-INFO +1 -1
- {flexitac-0.2.2 → flexitac-0.3.0}/LICENSE +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/README.md +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/examples/__init__.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/examples/stream_frames.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/examples/visualize_heatmap.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/find_port.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/firmware/__init__.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/firmware/template.ino +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/flash.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/logging_utils.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac/py.typed +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac.egg-info/SOURCES.txt +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac.egg-info/dependency_links.txt +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac.egg-info/entry_points.txt +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac.egg-info/requires.txt +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/flexitac.egg-info/top_level.txt +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/pyproject.toml +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/setup.cfg +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/tests/test_find_port.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/tests/test_flash.py +0 -0
- {flexitac-0.2.2 → flexitac-0.3.0}/tests/test_sensor.py +0 -0
|
@@ -40,7 +40,27 @@ class FlexiTacSensor:
|
|
|
40
40
|
noise_scale: float = 30.0,
|
|
41
41
|
init_frames: int = 30,
|
|
42
42
|
read_timeout_s: float = 5.0,
|
|
43
|
+
baseline: NDArray[np.float32] | float | None = None,
|
|
43
44
|
) -> None:
|
|
45
|
+
"""Initialize a FlexiTac sensor.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
port: Serial device path (e.g. ``/dev/ttyUSB0``).
|
|
49
|
+
rows: Number of tactile rows (default 12).
|
|
50
|
+
cols: Number of tactile columns (default 32).
|
|
51
|
+
baud: Serial baud rate matching the flashed firmware (default 2_000_000).
|
|
52
|
+
threshold: Contact-detection threshold in ADC counts above baseline.
|
|
53
|
+
noise_scale: Divisor used to normalize readings below ``threshold``.
|
|
54
|
+
init_frames: Number of frames sampled during ``calibrate()`` (default 30).
|
|
55
|
+
Higher values give a more robust baseline at the cost of startup time.
|
|
56
|
+
read_timeout_s: Maximum time ``read()`` will wait for a full frame.
|
|
57
|
+
baseline: If provided, skips auto-calibration on first ``read()``. Pass a
|
|
58
|
+
``(rows, cols)`` array of per-pixel baselines, or a scalar applied to
|
|
59
|
+
every pixel. Typical resting ADC values land around 10-40 for an
|
|
60
|
+
unloaded sensor, so a scalar like ``20.0`` is a reasonable default
|
|
61
|
+
when you can't afford the startup delay of a full calibration. For
|
|
62
|
+
accurate contact detection, prefer letting ``calibrate()`` run.
|
|
63
|
+
"""
|
|
44
64
|
self.port = port
|
|
45
65
|
self.rows = rows
|
|
46
66
|
self.cols = cols
|
|
@@ -56,6 +76,9 @@ class FlexiTacSensor:
|
|
|
56
76
|
self._baseline: NDArray[np.float32] | None = None
|
|
57
77
|
self._seq = 0
|
|
58
78
|
|
|
79
|
+
if baseline is not None:
|
|
80
|
+
self._baseline = np.broadcast_to(np.float32(baseline), (rows, cols)).astype(np.float32).copy()
|
|
81
|
+
|
|
59
82
|
def open(self) -> FlexiTacSensor:
|
|
60
83
|
"""Open the serial port if not already open."""
|
|
61
84
|
if self._serial is None or not self._serial.is_open:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|