scirodev 0.4.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scirodev
3
- Version: 0.4.0
3
+ Version: 0.4.1
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scirodev"
7
- version = "0.4.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 = _common.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``. Standard HSV of the raw reading; value is
130
- relative to the full scale of the current integration time.
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scirodev
3
- Version: 0.4.0
3
+ Version: 0.4.1
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
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