scirodev 0.1.0__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.
- {scirodev-0.1.0/scirodev.egg-info → scirodev-0.3.0}/PKG-INFO +5 -2
- {scirodev-0.1.0 → scirodev-0.3.0}/README.md +4 -1
- {scirodev-0.1.0 → scirodev-0.3.0}/pyproject.toml +1 -1
- {scirodev-0.1.0 → scirodev-0.3.0}/sciro/__init__.py +1 -1
- {scirodev-0.1.0 → scirodev-0.3.0}/sciro/_common.py +4 -0
- scirodev-0.3.0/sciro/floorpro.py +13 -0
- scirodev-0.3.0/sciro/hubs.py +76 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/sciro/iodevices.py +1 -1
- scirodev-0.1.0/sciro/floorpro.py → scirodev-0.3.0/sciro/pump.py +25 -2
- {scirodev-0.1.0 → scirodev-0.3.0/scirodev.egg-info}/PKG-INFO +5 -2
- {scirodev-0.1.0 → scirodev-0.3.0}/scirodev.egg-info/SOURCES.txt +2 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/LICENSE +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/sciro/parameters.py +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/sciro/py.typed +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/scirodev/__init__.py +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/scirodev/cli.py +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/scirodev.egg-info/dependency_links.txt +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/scirodev.egg-info/entry_points.txt +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/scirodev.egg-info/requires.txt +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/scirodev.egg-info/top_level.txt +0 -0
- {scirodev-0.1.0 → scirodev-0.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scirodev
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev
|
|
5
5
|
Author: Thomas Schank
|
|
6
6
|
License: MIT
|
|
@@ -41,10 +41,13 @@ Then your IDE/type checker knows these, which the upstream `pybricks` stubs don'
|
|
|
41
41
|
```python
|
|
42
42
|
from sciro.parameters import Port # Port.A .. Port.H (PeakHub has 8 ports)
|
|
43
43
|
from sciro.iodevices import PUMPDevice # generic PUMP device access
|
|
44
|
-
from sciro.
|
|
44
|
+
from sciro.pump import FloorPro # PUMP devices (LP-FloorPro, ...)
|
|
45
|
+
from sciro.hubs import PeakHub # hub class incl. display.device()
|
|
45
46
|
|
|
47
|
+
hub = PeakHub()
|
|
46
48
|
fp = FloorPro(Port.G)
|
|
47
49
|
cog_dark, cog_bright, brightness, darkness, mask, calibrating = fp.line.read()
|
|
50
|
+
hub.display.device(fp, brightness=50) # mirror the sensor's LED strip on the 5x5
|
|
48
51
|
```
|
|
49
52
|
|
|
50
53
|
On the hub these modules are frozen into the PeakHub firmware:
|
|
@@ -21,10 +21,13 @@ Then your IDE/type checker knows these, which the upstream `pybricks` stubs don'
|
|
|
21
21
|
```python
|
|
22
22
|
from sciro.parameters import Port # Port.A .. Port.H (PeakHub has 8 ports)
|
|
23
23
|
from sciro.iodevices import PUMPDevice # generic PUMP device access
|
|
24
|
-
from sciro.
|
|
24
|
+
from sciro.pump import FloorPro # PUMP devices (LP-FloorPro, ...)
|
|
25
|
+
from sciro.hubs import PeakHub # hub class incl. display.device()
|
|
25
26
|
|
|
27
|
+
hub = PeakHub()
|
|
26
28
|
fp = FloorPro(Port.G)
|
|
27
29
|
cog_dark, cog_bright, brightness, darkness, mask, calibrating = fp.line.read()
|
|
30
|
+
hub.display.device(fp, brightness=50) # mirror the sensor's LED strip on the 5x5
|
|
28
31
|
```
|
|
29
32
|
|
|
30
33
|
On the hub these modules are frozen into the PeakHub firmware:
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scirodev"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
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"
|
|
@@ -17,6 +17,8 @@ if TYPE_CHECKING:
|
|
|
17
17
|
_RGBC = Tuple[int, int, int, int, int]
|
|
18
18
|
_Euler = Tuple[float, float, float, int]
|
|
19
19
|
_StateData = Tuple[bytes, bytes]
|
|
20
|
+
_RGB = Tuple[int, int, int]
|
|
21
|
+
_Pixels = Tuple[_RGB, ...]
|
|
20
22
|
|
|
21
23
|
class MaybeAwaitableLine(_Line, Awaitable[_Line]): ...
|
|
22
24
|
|
|
@@ -29,3 +31,5 @@ if TYPE_CHECKING:
|
|
|
29
31
|
class MaybeAwaitableEuler(_Euler, Awaitable[_Euler]): ...
|
|
30
32
|
|
|
31
33
|
class MaybeAwaitableStateData(_StateData, Awaitable[_StateData]): ...
|
|
34
|
+
|
|
35
|
+
class MaybeAwaitablePixels(_Pixels, Awaitable[_Pixels]): ...
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""sciro.floorpro -- deprecated alias of :mod:`sciro.pump` (where the FloorPro
|
|
2
|
+
class lives now). Kept so older programs keep type-checking.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .pump import ( # noqa: F401 (re-exports)
|
|
6
|
+
IMU as IMU,
|
|
7
|
+
ColorSensor as ColorSensor,
|
|
8
|
+
FloorPro as FloorPro,
|
|
9
|
+
IRCalib as IRCalib,
|
|
10
|
+
IRRaw as IRRaw,
|
|
11
|
+
Line as Line,
|
|
12
|
+
Pixels as Pixels,
|
|
13
|
+
)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""sciro.hubs -- the PeakHub.
|
|
2
|
+
|
|
3
|
+
On the hub this module re-exports ``pybricks.hubs`` unchanged; the stub adds what
|
|
4
|
+
the upstream stubs lack: the ``PeakHub`` class and its ``display.device()``.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any, Optional, Protocol, Tuple
|
|
10
|
+
|
|
11
|
+
from pybricks import _common
|
|
12
|
+
from pybricks.hubs import PrimeHub as PrimeHub # noqa: F401 (re-export)
|
|
13
|
+
from pybricks.parameters import Axis as _Axis
|
|
14
|
+
from pybricks.parameters import Button as _Button
|
|
15
|
+
|
|
16
|
+
from .iodevices import PUMPDevice
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DisplaySource(Protocol):
|
|
20
|
+
"""Anything :meth:`LightMatrix.device` can show: an object whose
|
|
21
|
+
``_display_source()`` returns ``(PUMPDevice, stream id, map)``.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def _display_source(self) -> Tuple[PUMPDevice, int, Tuple[Optional[int], ...]]: ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class LightMatrix(_common.LightMatrix):
|
|
28
|
+
"""The PeakHub's 5x5 RGB matrix: everything ``pybricks`` offers, plus a
|
|
29
|
+
background mirror of a PUMP device's display stream.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def device(self, device: DisplaySource, brightness: int = 100) -> None:
|
|
33
|
+
"""device(device, brightness=100)
|
|
34
|
+
|
|
35
|
+
Shows the device's own display (e.g. the LP-FloorPro's LED strip) on
|
|
36
|
+
the matrix, updated in the background at the device's rate until
|
|
37
|
+
:meth:`off` or any other drawing call. The device stops streaming when
|
|
38
|
+
the program ends.
|
|
39
|
+
|
|
40
|
+
Arguments:
|
|
41
|
+
device (FloorPro): The device to mirror (any ``sciro.pump`` device with a display stream).
|
|
42
|
+
brightness (Number, %): Brightness of the mirrored pixels, 0 .. 1000.
|
|
43
|
+
Above 100 the picture is amplified (clipping at full), since
|
|
44
|
+
the matrix is far dimmer than a sensor's own LED strip.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class PeakHub:
|
|
49
|
+
"""LEGO-compatible hub by Sciurus Robotics: 8 ports, 5x5 RGB matrix, IMU."""
|
|
50
|
+
|
|
51
|
+
# Class attributes for documentation/typing only; the firmware creates
|
|
52
|
+
# them as instance attributes in __init__.
|
|
53
|
+
battery = _common.Battery()
|
|
54
|
+
buttons = _common.Keypad([_Button.LEFT, _Button.RIGHT, _Button.CENTER, _Button.BLUETOOTH])
|
|
55
|
+
charger = _common.Charger()
|
|
56
|
+
display = LightMatrix(5, 5)
|
|
57
|
+
imu = _common.IMU()
|
|
58
|
+
speaker = _common.Speaker()
|
|
59
|
+
system = _common.System()
|
|
60
|
+
ble = _common.BLE()
|
|
61
|
+
|
|
62
|
+
def __init__(
|
|
63
|
+
self,
|
|
64
|
+
top_side: Any = _Axis.Z,
|
|
65
|
+
front_side: Any = _Axis.X,
|
|
66
|
+
broadcast_channel: int = 0,
|
|
67
|
+
observe_channels: Any = (),
|
|
68
|
+
):
|
|
69
|
+
"""PeakHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
|
70
|
+
|
|
71
|
+
Arguments:
|
|
72
|
+
top_side (Axis): The axis that passes through the *top side* of the hub.
|
|
73
|
+
front_side (Axis): The axis that passes through the *front side* of the hub.
|
|
74
|
+
broadcast_channel: Channel for broadcasting data (0 .. 255).
|
|
75
|
+
observe_channels: Channels to observe.
|
|
76
|
+
"""
|
|
@@ -21,7 +21,7 @@ class PUMPDevice:
|
|
|
21
21
|
"""Generic access to a PUMP device (Power UART Multiplex Protocol) on a
|
|
22
22
|
PeakHub port. Streams are addressed by id (1..N); state and data are raw
|
|
23
23
|
``bytes`` decoded by the user or a convenience class such as
|
|
24
|
-
:class:`sciro.
|
|
24
|
+
:class:`sciro.pump.FloorPro`. Spec: ``PUMP-Protocol.md``.
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
OFF: int = 0
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
"""sciro.
|
|
1
|
+
"""sciro.pump -- PUMP devices on the PeakHub, the PUMP counterpart of
|
|
2
|
+
``pybricks.pupdevices``: the generic :class:`PUMPDevice` plus one class per
|
|
3
|
+
device (currently the LP-FloorPro line sensor).
|
|
2
4
|
|
|
3
5
|
Stub for the frozen module of the same name. Every reading method returns the
|
|
4
6
|
value directly, or an awaitable under multitasking.
|
|
@@ -16,10 +18,12 @@ if TYPE_CHECKING:
|
|
|
16
18
|
MaybeAwaitableInts,
|
|
17
19
|
MaybeAwaitableIRCalib,
|
|
18
20
|
MaybeAwaitableLine,
|
|
21
|
+
MaybeAwaitablePixels,
|
|
19
22
|
MaybeAwaitableRGBC,
|
|
20
23
|
)
|
|
21
24
|
|
|
22
|
-
from .iodevices import PUMPDevice
|
|
25
|
+
from .iodevices import PUMPDevice as PUMPDevice # noqa: F401 (re-export)
|
|
26
|
+
from .iodevices import StreamInfo
|
|
23
27
|
from .parameters import Port as _Port
|
|
24
28
|
|
|
25
29
|
|
|
@@ -75,6 +79,20 @@ class IRCalib(_Stream):
|
|
|
75
79
|
"""oneshot() -> Tuple -- request the table once and return it."""
|
|
76
80
|
|
|
77
81
|
|
|
82
|
+
class Pixels(_Stream):
|
|
83
|
+
"""The sensor's own LED strip picture, rendered on the device at full scale:
|
|
84
|
+
18 ``(r, g, b)`` triplets = IR channels 0..14, EXT1, EXT2, battery. Off by
|
|
85
|
+
default. A PeakHub mirrors it on its 5x5 matrix with
|
|
86
|
+
:meth:`sciro.hubs.LightMatrix.device`.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def read(self) -> MaybeAwaitablePixels:
|
|
90
|
+
"""read() -> Tuple[Tuple[int, int, int], ...] -- 18 RGB triplets, 0 .. 255."""
|
|
91
|
+
|
|
92
|
+
def oneshot(self) -> MaybeAwaitablePixels:
|
|
93
|
+
"""oneshot() -> Tuple -- request one frame and return it."""
|
|
94
|
+
|
|
95
|
+
|
|
78
96
|
class ColorSensor(_Stream):
|
|
79
97
|
"""TCS3400 on an extension port: raw R, G, B, C at device resolution.
|
|
80
98
|
|
|
@@ -126,6 +144,8 @@ class FloorPro:
|
|
|
126
144
|
line: Line
|
|
127
145
|
ir_raw: IRRaw
|
|
128
146
|
ir_calib: IRCalib
|
|
147
|
+
pixels: Pixels
|
|
148
|
+
"""The strip picture stream; ``None`` with firmware that lacks it."""
|
|
129
149
|
|
|
130
150
|
def __init__(self, port: _Port):
|
|
131
151
|
"""FloorPro(port)
|
|
@@ -146,3 +166,6 @@ class FloorPro:
|
|
|
146
166
|
|
|
147
167
|
def streams(self) -> Tuple[StreamInfo, ...]:
|
|
148
168
|
"""streams() -> Tuple -- the enumerated streams ``(id, url, ext_port, state_len)``."""
|
|
169
|
+
|
|
170
|
+
def _display_source(self) -> Tuple[PUMPDevice, int, Tuple[Optional[int], ...]]:
|
|
171
|
+
"""(device, stream id, matrix map) consumed by ``hub.display.device()``."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scirodev
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev
|
|
5
5
|
Author: Thomas Schank
|
|
6
6
|
License: MIT
|
|
@@ -41,10 +41,13 @@ Then your IDE/type checker knows these, which the upstream `pybricks` stubs don'
|
|
|
41
41
|
```python
|
|
42
42
|
from sciro.parameters import Port # Port.A .. Port.H (PeakHub has 8 ports)
|
|
43
43
|
from sciro.iodevices import PUMPDevice # generic PUMP device access
|
|
44
|
-
from sciro.
|
|
44
|
+
from sciro.pump import FloorPro # PUMP devices (LP-FloorPro, ...)
|
|
45
|
+
from sciro.hubs import PeakHub # hub class incl. display.device()
|
|
45
46
|
|
|
47
|
+
hub = PeakHub()
|
|
46
48
|
fp = FloorPro(Port.G)
|
|
47
49
|
cog_dark, cog_bright, brightness, darkness, mask, calibrating = fp.line.read()
|
|
50
|
+
hub.display.device(fp, brightness=50) # mirror the sensor's LED strip on the 5x5
|
|
48
51
|
```
|
|
49
52
|
|
|
50
53
|
On the hub these modules are frozen into the PeakHub firmware:
|
|
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
|