scirodev 0.3.1__tar.gz → 0.4.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.
- {scirodev-0.3.1 → scirodev-0.4.1}/PKG-INFO +1 -1
- {scirodev-0.3.1 → scirodev-0.4.1}/pyproject.toml +1 -1
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/_common.py +7 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/floorpro.py +1 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/hubs.py +29 -1
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/pump.py +59 -13
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev.egg-info/PKG-INFO +1 -1
- {scirodev-0.3.1 → scirodev-0.4.1}/LICENSE +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/README.md +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/__init__.py +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/iodevices.py +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/parameters.py +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/sciro/py.typed +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev/__init__.py +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev/cli.py +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev.egg-info/SOURCES.txt +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev.egg-info/dependency_links.txt +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev.egg-info/entry_points.txt +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev.egg-info/requires.txt +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/scirodev.egg-info/top_level.txt +0 -0
- {scirodev-0.3.1 → scirodev-0.4.1}/setup.cfg +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scirodev"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.1"
|
|
8
8
|
description = "PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -18,6 +18,7 @@ if TYPE_CHECKING:
|
|
|
18
18
|
_Euler = Tuple[float, float, float, int]
|
|
19
19
|
_StateData = Tuple[bytes, bytes]
|
|
20
20
|
_RGB = Tuple[int, int, int]
|
|
21
|
+
_Calibration = Tuple[Tuple[int, int, int, int], Tuple[int, int, int, int], Tuple[int, int, int], bool, bool, int]
|
|
21
22
|
_Pixels = Tuple[_RGB, ...]
|
|
22
23
|
|
|
23
24
|
class MaybeAwaitableLine(_Line, Awaitable[_Line]): ...
|
|
@@ -33,3 +34,9 @@ if TYPE_CHECKING:
|
|
|
33
34
|
class MaybeAwaitableStateData(_StateData, Awaitable[_StateData]): ...
|
|
34
35
|
|
|
35
36
|
class MaybeAwaitablePixels(_Pixels, Awaitable[_Pixels]): ...
|
|
37
|
+
|
|
38
|
+
class MaybeAwaitableRGB8(_RGB, Awaitable[_RGB]): ...
|
|
39
|
+
|
|
40
|
+
class MaybeAwaitableCalibration(_Calibration, Awaitable[_Calibration]): ...
|
|
41
|
+
|
|
42
|
+
class MaybeAwaitableStr(str, Awaitable[str]): ...
|
|
@@ -45,6 +45,34 @@ class LightMatrix(_common.LightMatrix):
|
|
|
45
45
|
"""
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
class System(_common.System):
|
|
49
|
+
"""The PeakHub's system object: everything ``pybricks`` offers, plus the
|
|
50
|
+
board identity.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def device_id(self) -> str:
|
|
54
|
+
"""device_id() -> str
|
|
55
|
+
|
|
56
|
+
The full factory unique ID of the hub's MCU as a 24-character uppercase
|
|
57
|
+
hex string. Stable per physical hub.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def short_id(self) -> str:
|
|
61
|
+
"""short_id() -> str
|
|
62
|
+
|
|
63
|
+
The hub's 8-character short ID (Crockford base32, derived from the
|
|
64
|
+
device ID): the same value the boot console prints and the device
|
|
65
|
+
inventory uses.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
def info(self) -> dict:
|
|
69
|
+
"""info() -> dict
|
|
70
|
+
|
|
71
|
+
``{"name", "device_id", "short_id", "reset_reason", "program_id",
|
|
72
|
+
"program_start_type"}`` in one call.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
|
|
48
76
|
class PeakHub:
|
|
49
77
|
"""LEGO-compatible hub by Sciurus Robotics: 8 ports, 5x5 RGB matrix, IMU."""
|
|
50
78
|
|
|
@@ -56,7 +84,7 @@ class PeakHub:
|
|
|
56
84
|
display = LightMatrix(5, 5)
|
|
57
85
|
imu = _common.IMU()
|
|
58
86
|
speaker = _common.Speaker()
|
|
59
|
-
system =
|
|
87
|
+
system = System()
|
|
60
88
|
ble = _common.BLE()
|
|
61
89
|
|
|
62
90
|
def __init__(
|
|
@@ -19,6 +19,9 @@ if TYPE_CHECKING:
|
|
|
19
19
|
MaybeAwaitableIRCalib,
|
|
20
20
|
MaybeAwaitableLine,
|
|
21
21
|
MaybeAwaitablePixels,
|
|
22
|
+
MaybeAwaitableRGB8,
|
|
23
|
+
MaybeAwaitableCalibration,
|
|
24
|
+
MaybeAwaitableStr,
|
|
22
25
|
MaybeAwaitableRGBC,
|
|
23
26
|
)
|
|
24
27
|
|
|
@@ -122,12 +125,48 @@ class ColorSensor(_Stream):
|
|
|
122
125
|
def read(self) -> MaybeAwaitableRGBC:
|
|
123
126
|
"""read() -> Tuple[int, int, int, int, int] -- raw (red, green, blue, clear, status) at device resolution."""
|
|
124
127
|
|
|
128
|
+
def calibrated(self) -> MaybeAwaitableRGB8:
|
|
129
|
+
"""calibrated() -> Tuple[int, int, int]
|
|
130
|
+
|
|
131
|
+
Red, green, blue 0 .. 255 as the device itself shows them: stretched
|
|
132
|
+
over the calibrated range when a valid calibration applies, scaled to
|
|
133
|
+
full scale otherwise.
|
|
134
|
+
"""
|
|
135
|
+
|
|
125
136
|
def hsv(self) -> MaybeAwaitableColor:
|
|
126
137
|
"""hsv() -> Color
|
|
127
138
|
|
|
128
139
|
Hue (0 .. 359), saturation (0 .. 100) and value (0 .. 100) of the
|
|
129
|
-
surface, as a ``Color
|
|
130
|
-
|
|
140
|
+
surface, as a ``Color``: standard HSV of the calibrated colour when a
|
|
141
|
+
valid calibration applies, of the raw reading otherwise.
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
def calibration_status(self) -> MaybeAwaitableStr:
|
|
145
|
+
"""calibration_status() -> str
|
|
146
|
+
|
|
147
|
+
``"none"`` (nothing stored), ``"weak"`` (stored but not applicable:
|
|
148
|
+
incomplete, or LED / gain / integration differ from the calibration
|
|
149
|
+
profile), ``"ok"`` (applied), or ``"calibrating"``.
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
def calibrate(self, enable: bool = True) -> MaybeAwaitable:
|
|
153
|
+
"""calibrate(enable=True)
|
|
154
|
+
|
|
155
|
+
Start or stop the range calibration on the device. While it runs, move
|
|
156
|
+
the sensor over the darkest and brightest surfaces (or elements) it
|
|
157
|
+
will see; stopping stores the table on the sensor, bound to the LED,
|
|
158
|
+
gain and integration time in force. Changing those meanwhile aborts it.
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
def clear_calibration(self) -> MaybeAwaitable:
|
|
162
|
+
"""clear_calibration() -- drop the stored calibration (back to full-scale colour)."""
|
|
163
|
+
|
|
164
|
+
def calibration(self) -> MaybeAwaitableCalibration:
|
|
165
|
+
"""calibration() -> Tuple
|
|
166
|
+
|
|
167
|
+
The stored table: ``(min, max, (led, gain, atime), valid, applicable,
|
|
168
|
+
visited_mask)`` with ``min``/``max`` tuples of four counts (red, green,
|
|
169
|
+
blue, clear). Fetched from the device on demand.
|
|
131
170
|
"""
|
|
132
171
|
|
|
133
172
|
def color(self) -> MaybeAwaitableColor:
|
|
@@ -153,24 +192,24 @@ class ColorSensor(_Stream):
|
|
|
153
192
|
"""set_integration(atime) -- TCS3400 ATIME register 0 .. 255: (256 - atime) * 2.78 ms."""
|
|
154
193
|
|
|
155
194
|
|
|
156
|
-
class
|
|
157
|
-
"""BNO086
|
|
195
|
+
class Gyro(_Stream):
|
|
196
|
+
"""Gyro (BNO086) on an extension port of a PUMP device: roll, pitch, yaw in degrees.
|
|
158
197
|
|
|
159
|
-
``
|
|
160
|
-
same class. The heading offset lives on the hub:
|
|
161
|
-
the current yaw read as the given angle.
|
|
198
|
+
``Gyro(port, ext_port)`` opens it directly; :meth:`FloorPro.gyro` returns the
|
|
199
|
+
same class (``IMU`` is an alias). The heading offset lives on the hub:
|
|
200
|
+
:meth:`reset_heading` makes the current yaw read as the given angle.
|
|
162
201
|
"""
|
|
163
202
|
|
|
164
203
|
ext_port: int
|
|
165
204
|
|
|
166
205
|
def __init__(self, port: Union[_Port, PUMPDevice], ext_port: int = 2):
|
|
167
|
-
"""
|
|
206
|
+
"""Gyro(port, ext_port=ExtPort.EXT2)
|
|
168
207
|
|
|
169
208
|
Arguments:
|
|
170
|
-
port (Port): Hub port of the PUMP device carrying the
|
|
209
|
+
port (Port): Hub port of the PUMP device carrying the gyro (or the
|
|
171
210
|
opened ``PUMPDevice`` itself).
|
|
172
|
-
ext_port (ExtPort): Extension port the
|
|
173
|
-
``OSError`` if there is no
|
|
211
|
+
ext_port (ExtPort): Extension port the gyro is plugged into. Raises
|
|
212
|
+
``OSError`` if there is no gyro there.
|
|
174
213
|
"""
|
|
175
214
|
|
|
176
215
|
def read(self) -> MaybeAwaitableEuler:
|
|
@@ -183,6 +222,10 @@ class IMU(_Stream):
|
|
|
183
222
|
"""reset_heading(angle=0) -- make the current heading read as ``angle``."""
|
|
184
223
|
|
|
185
224
|
|
|
225
|
+
IMU = Gyro
|
|
226
|
+
"""Alias of :class:`Gyro`."""
|
|
227
|
+
|
|
228
|
+
|
|
186
229
|
class FloorPro:
|
|
187
230
|
"""LP-FloorPro connected to a PeakHub port, speaking PUMP."""
|
|
188
231
|
|
|
@@ -210,8 +253,11 @@ class FloorPro:
|
|
|
210
253
|
The TCS3400 on extension port 1 or 2; raises ``OSError`` if none.
|
|
211
254
|
"""
|
|
212
255
|
|
|
213
|
-
def
|
|
214
|
-
"""
|
|
256
|
+
def gyro(self, ext_port: int = 2) -> Gyro:
|
|
257
|
+
"""gyro(ext_port=2) -> Gyro -- the gyro on extension port 1 or 2; raises ``OSError`` if none."""
|
|
258
|
+
|
|
259
|
+
def imu(self, ext_port: int = 2) -> Gyro:
|
|
260
|
+
"""imu(ext_port=2) -> Gyro -- alias of :meth:`gyro`."""
|
|
215
261
|
|
|
216
262
|
def streams(self) -> Tuple[StreamInfo, ...]:
|
|
217
263
|
"""streams() -> Tuple -- the enumerated streams ``(id, url, ext_port, state_len)``."""
|
|
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
|