pybricks 3.6.0b5__tar.gz → 4.0.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.
Files changed (39) hide show
  1. {pybricks-3.6.0b5 → pybricks-4.0.0}/PKG-INFO +5 -2
  2. {pybricks-3.6.0b5 → pybricks-4.0.0}/pyproject.toml +1 -1
  3. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/_common.py +19 -106
  4. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/ev3devices.py +4 -4
  5. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/hubs.py +9 -75
  6. pybricks-4.0.0/src/pybricks/iodevices.py +694 -0
  7. pybricks-4.0.0/src/pybricks/messaging.py +465 -0
  8. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/parameters.py +22 -9
  9. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/pupdevices.py +221 -23
  10. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/robotics.py +67 -31
  11. pybricks-3.6.0b5/src/pybricks/iodevices.py +0 -452
  12. pybricks-3.6.0b5/src/pybricks/messaging.py +0 -233
  13. {pybricks-3.6.0b5 → pybricks-4.0.0}/AUTHORS.md +0 -0
  14. {pybricks-3.6.0b5 → pybricks-4.0.0}/LICENSE +0 -0
  15. {pybricks-3.6.0b5 → pybricks-4.0.0}/README.rst +0 -0
  16. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/micropython/__init__.py +0 -0
  17. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/micropython/py.typed +0 -0
  18. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/__init__.py +0 -0
  19. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/ev3dev/_speaker.py +0 -0
  20. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/media/__init__.py +0 -0
  21. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/media/ev3dev.py +0 -0
  22. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/media/py.typed +0 -0
  23. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/nxtdevices.py +0 -0
  24. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/py.typed +0 -0
  25. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/pybricks/tools.py +0 -0
  26. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/uerrno/__init__.py +0 -0
  27. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/uerrno/py.typed +0 -0
  28. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/uio/__init__.py +0 -0
  29. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/uio/py.typed +0 -0
  30. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/ujson/__init__.py +0 -0
  31. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/umath/__init__.py +0 -0
  32. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/umath/py.typed +0 -0
  33. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/urandom/__init__.py +0 -0
  34. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/urandom/py.typed +0 -0
  35. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/uselect/__init__.py +0 -0
  36. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/uselect/py.typed +0 -0
  37. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/ustruct/__init__.py +0 -0
  38. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/usys/__init__.py +0 -0
  39. {pybricks-3.6.0b5 → pybricks-4.0.0}/src/usys/py.typed +0 -0
@@ -1,8 +1,10 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: pybricks
3
- Version: 3.6.0b5
3
+ Version: 4.0.0
4
4
  Summary: Documentation and user-API stubs for Pybricks MicroPython
5
5
  License: MIT
6
+ License-File: AUTHORS.md
7
+ License-File: LICENSE
6
8
  Author: The Pybricks Authors
7
9
  Author-email: team@pybricks.com
8
10
  Maintainer: Laurens Valk
@@ -16,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
16
18
  Classifier: Programming Language :: Python :: 3.11
17
19
  Classifier: Programming Language :: Python :: 3.12
18
20
  Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
19
22
  Classifier: Programming Language :: Python :: Implementation :: MicroPython
20
23
  Project-URL: Documentation, https://docs.pybricks.com
21
24
  Project-URL: Homepage, https://pybricks.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pybricks"
3
- version = "3.6.0b5"
3
+ version = "4.0.0"
4
4
  description = "Documentation and user-API stubs for Pybricks MicroPython"
5
5
  authors = ["The Pybricks Authors <team@pybricks.com>"]
6
6
  maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
@@ -40,6 +40,8 @@ if TYPE_CHECKING:
40
40
 
41
41
  class MaybeAwaitableColor(Color, Awaitable[Color]): ...
42
42
 
43
+ class MaybeAwaitableBytes(bytes, Awaitable[bytes]): ...
44
+
43
45
 
44
46
  class System:
45
47
  """System control actions for a hub."""
@@ -123,12 +125,15 @@ class System:
123
125
  automatically, like after a firmware update. It is ``2`` if the hub
124
126
  previously crashed due to a watchdog timeout, which indicates a
125
127
  firmware issue.
126
- - ``"host_connected_ble"``: Whether the hub is connected to a computer,
127
- tablet, or phone via Bluetooth.
128
+ - ``"host_connected_ble"``: ``True`` if the hub is connected to a
129
+ computer, tablet, or phone via Bluetooth, and ``False`` otherwise.
130
+ - ``"host_connected_usb"``: ``True`` if the hub is connected to a computer
131
+ via USB and activated in the app. ``False`` otherwise.
128
132
  - ``"program_start_type"``: It is ``1`` if the program started
129
133
  automatically when the hub was powered on. It is ``2`` if the program
130
134
  was started with the hub buttons. It is ``3`` if the program was
131
135
  started from your connected computer.
136
+ - `"program_id"`: Program (slot) number of the currently running program.
132
137
 
133
138
  Returns:
134
139
  A dictionary with system info.
@@ -136,7 +141,7 @@ class System:
136
141
  .. versionchanged:: 3.6
137
142
  The name and reset reason where previously available as separate
138
143
  methods. Now they are included in the info dictionary. The methods
139
- are still available for compatibility.
144
+ are still available for backwards compatibility.
140
145
  """
141
146
 
142
147
 
@@ -828,7 +833,7 @@ class LightMatrix:
828
833
  contents remain unchanged.
829
834
 
830
835
  Arguments:
831
- top (Side): Which side of the light matrix display is "up" in your
836
+ up (Side): Which side of the light matrix display is "up" in your
832
837
  design. Choose ``Side.TOP``, ``Side.LEFT``, ``Side.RIGHT``,
833
838
  or ``Side.BOTTOM``.
834
839
  """
@@ -1165,7 +1170,7 @@ class IMU:
1165
1170
  hub consistently reports a different value for a full rotation. For
1166
1171
  example, your hub might consistently report `357` degrees for every
1167
1172
  `360` degree turn. You can measure this value
1168
- with ``hub.imu.rotation(-Axis.Z)`` and enter it as
1173
+ with ``hub.imu.rotation(-Axis.Z, calibrated=False)`` and enter it as
1169
1174
  the ``heading_correction`` setting. Then, the ``hub.imu.heading()``
1170
1175
  method will take it into account going forward, correctly scaling it
1171
1176
  to 360 degrees for a full rotation.
@@ -1179,17 +1184,19 @@ class IMU:
1179
1184
  variations in acceleration below which the hub is considered
1180
1185
  stationary enough to calibrate. After a reset the value
1181
1186
  is 2500 mm/s².
1182
- heading_correction (Number, deg): Number of degrees reported by
1183
- ``imu.rotation(-Axis.Z)`` for one full rotation of your robot.
1184
- After a reset the value is 360 degrees.
1187
+ heading_correction (Number, deg): Number of degrees
1188
+ reported by for one full rotation of your robot.
1189
+ After a reset the value is 360 degrees. This is applied on top
1190
+ of any scaling that is done by the ``angular_velocity_scale``
1191
+ setting.
1185
1192
  angular_velocity_bias (tuple, deg/s): Initial bias for angular
1186
1193
  velocity measurements along x, y, and z immediately after boot.
1187
1194
  After a reset the value is (0, 0, 0) deg/s.
1188
1195
  angular_velocity_scale (tuple, deg): Scale adjustment for x, y, and
1189
- z rotation to account for manufacturing differences. After a reset the
1190
- value is (360, 360, 360) deg/s. The correct values can be
1191
- obtained using `hub.imu.rotation(Axis.X, calibrated=False)` and
1192
- repeating it for each axis.
1196
+ z rotation to account for manufacturing differences. After a
1197
+ reset the value is (360, 360, 360) deg/s. The correct values
1198
+ can be obtained using `hub.imu.rotation(Axis.X, calibrated=False)`
1199
+ and repeating it for each axis.
1193
1200
  acceleration_correction (tuple, mm/s²): Scale adjustment for x, y,
1194
1201
  and z gravity magnitude in both directions to account for
1195
1202
  manufacturing differences. After a reset the
@@ -1209,17 +1216,6 @@ class IMU:
1209
1216
  even as the robot turns more than 180 degrees. It does not wrap around
1210
1217
  to -180 like it does in some apps.
1211
1218
 
1212
-
1213
- .. note:: *For now, this method only keeps track of the heading while
1214
- the robot is on a flat surface.*
1215
-
1216
- This means that the value is
1217
- no longer correct if you lift it from the table or turn on
1218
- a ramp. Try ``hub.imu.heading('3D')`` for a heading value
1219
- that compensates for this. This will become the default in a
1220
- future release. If you try it, please let us know on our
1221
- forums!
1222
-
1223
1219
  Returns:
1224
1220
  Heading angle relative to starting orientation.
1225
1221
 
@@ -1437,86 +1433,3 @@ class AmbientColorSensor(CommonColorSensor):
1437
1433
  Measured color. The color is described by a hue (0--359), a
1438
1434
  saturation (0--100), and a brightness value (0--100).
1439
1435
  """
1440
-
1441
-
1442
- class BLE:
1443
- """
1444
- Bluetooth Low Energy.
1445
-
1446
- .. versionadded:: 3.3
1447
- """
1448
-
1449
- def broadcast(self, data: Union[bool, int, float, str, bytes]) -> MaybeAwaitable:
1450
- """broadcast(data)
1451
-
1452
- Starts broadcasting the given data on
1453
- the ``broadcast_channel`` you selected when initializing the hub.
1454
-
1455
- Data may be of type ``int``, ``float``, ``str``, ``bytes``,
1456
- ``True``, or ``False``. It can also be a list or tuple of these.
1457
-
1458
- Choose ``None`` to stop broadcasting. This helps improve performance
1459
- when you don't need the broadcast feature, especially when observing
1460
- at the same time.
1461
-
1462
- The total data size is quite limited (26 bytes). ``True`` and
1463
- ``False`` take 1 byte each. ``float`` takes 5 bytes. ``int`` takes 2 to
1464
- 5 bytes depending on how big the number is. ``str`` and ``bytes`` take
1465
- the number of bytes in the object plus one extra byte.
1466
-
1467
- When multitasking, only one task can broadcast at a time. To broadcast
1468
- information from multiple tasks (or block stacks), you could use a
1469
- dedicated separate task that broadcast new values when one or more
1470
- variables change.
1471
-
1472
- Args:
1473
- data: The value or values to be broadcast.
1474
-
1475
- .. versionadded:: 3.3
1476
- """
1477
-
1478
- def observe(
1479
- self, channel: int
1480
- ) -> Optional[Tuple[Union[bool, int, float, str, bytes], ...]]:
1481
- """observe(channel) -> bool | int | float | str | bytes | tuple | None
1482
-
1483
- Retrieves the last observed data for a given channel.
1484
-
1485
- Receiving data is more reliable when the hub is not connected
1486
- to a computer or other devices at the same time.
1487
-
1488
- Args:
1489
- channel (int): The channel to observe (0 to 255).
1490
-
1491
- Returns:
1492
- The received data in the same format as it was sent, or ``None``
1493
- if no recent data is available.
1494
-
1495
- .. versionadded:: 3.3
1496
- """
1497
-
1498
- def signal_strength(self, channel: int) -> int:
1499
- """signal_strength(channel) -> int: dBm
1500
-
1501
- Gets the average signal strength in dBm for the given channel.
1502
-
1503
- This indicates how near the broadcasting device is. Nearby devices
1504
- may have a signal strength around -40 dBm, while far away devices
1505
- might have a signal strength around -70 dBm.
1506
-
1507
- Args:
1508
- channel (int): The channel number (0 to 255).
1509
-
1510
- Returns:
1511
- The signal strength or ``-128`` if there is no recent observed data.
1512
-
1513
- .. versionadded:: 3.3
1514
- """
1515
-
1516
- def version(self) -> str:
1517
- """version() -> str
1518
-
1519
- Gets the firmware version from the Bluetooth chip.
1520
-
1521
- .. versionadded:: 3.3
1522
- """
@@ -3,7 +3,7 @@
3
3
 
4
4
  """LEGO® MINDSTORMS® EV3 motors and sensors."""
5
5
 
6
- from typing import Optional, Tuple, List
6
+ from typing import Optional, Tuple, List, Set
7
7
 
8
8
  from . import _common
9
9
  from .parameters import (
@@ -57,7 +57,7 @@ class ColorSensor:
57
57
  Returns:
58
58
  ``Color.BLACK``, ``Color.BLUE``, ``Color.GREEN``,
59
59
  ``Color.YELLOW``, ``Color.RED``, ``Color.WHITE``, ``Color.BROWN``,
60
- or ``None`` if no color is detected.
60
+ or ``Color.NONE`` if no color is detected.
61
61
 
62
62
  """
63
63
 
@@ -134,8 +134,8 @@ class InfraredSensor:
134
134
  a tuple of (``None``, ``None``) if no remote is detected.
135
135
  """
136
136
 
137
- def buttons(self, channel: int) -> List[_Button]:
138
- """buttons(channel) -> List[Button]
137
+ def buttons(self, channel: int) -> Set[_Button]:
138
+ """buttons(channel) -> Set[Button]
139
139
 
140
140
  Checks which buttons on the infrared remote are pressed.
141
141
 
@@ -3,8 +3,6 @@
3
3
 
4
4
  """LEGO® Programmable Hubs."""
5
5
 
6
- from typing import Sequence
7
-
8
6
  from . import _common
9
7
  from .ev3dev import _speaker
10
8
  from .media.ev3dev import Image as _Image
@@ -41,28 +39,19 @@ class MoveHub:
41
39
  imu = _common.SimpleAccelerometer()
42
40
  system = _common.System()
43
41
  buttons = _common.Keypad([_Button.CENTER])
44
- ble = _common.BLE()
45
42
 
46
43
  def __init__(
47
- self, broadcast_channel: int = None, observe_channels: Sequence[int] = []
44
+ self,
45
+ top_side: Axis = Axis.Z,
46
+ front_side: Axis = Axis.X,
48
47
  ):
49
- """MoveHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=None, observe_channels=[])
48
+ """MoveHub(top_side=Axis.Z, front_side=Axis.X)
50
49
 
51
50
  Arguments:
52
51
  top_side (Axis): The axis that passes through the *top side* of
53
52
  the hub.
54
53
  front_side (Axis): The axis that passes through the *front side* of
55
54
  the hub.
56
- broadcast_channel:
57
- Channel number (0 to 255) used to broadcast data.
58
- Choose ``None`` when not using broadcasting.
59
- observe_channels:
60
- A list of channels to listen to when ``hub.ble.observe()`` is
61
- called. Listening to more channels requires more memory.
62
- Default is an empty list (no channels).
63
-
64
- .. versionchanged:: 3.3
65
- Added *broadcast_channel* and *observe_channels* arguments.
66
55
  """
67
56
 
68
57
 
@@ -75,25 +64,9 @@ class CityHub:
75
64
  light = _common.ColorLight()
76
65
  system = _common.System()
77
66
  buttons = _common.Keypad([_Button.CENTER])
78
- ble = _common.BLE()
79
67
 
80
- def __init__(
81
- self, broadcast_channel: int = None, observe_channels: Sequence[int] = []
82
- ):
83
- """CityHub(broadcast_channel=None, observe_channels=[])
84
-
85
- Arguments:
86
- broadcast_channel:
87
- Channel number (0 to 255) used to broadcast data.
88
- Choose ``None`` when not using broadcasting.
89
- observe_channels:
90
- A list of channels to listen to when ``hub.ble.observe()`` is
91
- called. Listening to more channels requires more memory.
92
- Default is an empty list (no channels).
93
-
94
- .. versionchanged:: 3.3
95
- Added *broadcast_channel* and *observe_channels* arguments.
96
- """
68
+ def __init__(self):
69
+ """CityHub()"""
97
70
 
98
71
 
99
72
  class TechnicHub:
@@ -106,16 +79,13 @@ class TechnicHub:
106
79
  imu = _common.IMU()
107
80
  system = _common.System()
108
81
  buttons = _common.Keypad([_Button.CENTER])
109
- ble = _common.BLE()
110
82
 
111
83
  def __init__(
112
84
  self,
113
85
  top_side: Axis = Axis.Z,
114
86
  front_side: Axis = Axis.X,
115
- broadcast_channel: int = None,
116
- observe_channels: Sequence[int] = [],
117
87
  ):
118
- """TechnicHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=None, observe_channels=[])
88
+ """TechnicHub(top_side=Axis.Z, front_side=Axis.X)
119
89
 
120
90
  Initializes the hub. Optionally, specify how the hub is
121
91
  :ref:`placed in your design <robotframe>` by saying in which
@@ -127,16 +97,6 @@ class TechnicHub:
127
97
  the hub.
128
98
  front_side (Axis): The axis that passes through the *front side* of
129
99
  the hub.
130
- broadcast_channel:
131
- Channel number (0 to 255) used to broadcast data.
132
- Choose ``None`` when not using broadcasting.
133
- observe_channels:
134
- A list of channels to listen to when ``hub.ble.observe()`` is
135
- called. Listening to more channels requires more memory.
136
- Default is an empty list (no channels).
137
-
138
- .. versionchanged:: 3.3
139
- Added *broadcast_channel* and *observe_channels* arguments.
140
100
  """
141
101
 
142
102
 
@@ -151,16 +111,13 @@ class EssentialHub:
151
111
  light = _common.ColorLight()
152
112
  imu = _common.IMU()
153
113
  system = _common.System()
154
- ble = _common.BLE()
155
114
 
156
115
  def __init__(
157
116
  self,
158
117
  top_side: Axis = Axis.Z,
159
118
  front_side: Axis = Axis.X,
160
- broadcast_channel: int = None,
161
- observe_channels: Sequence[int] = [],
162
119
  ):
163
- """EssentialHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=None, observe_channels=[])
120
+ """EssentialHub(top_side=Axis.Z, front_side=Axis.X)
164
121
 
165
122
  Initializes the hub. Optionally, specify how the hub is
166
123
  :ref:`placed in your design <robotframe>` by saying in which
@@ -172,16 +129,6 @@ class EssentialHub:
172
129
  the hub.
173
130
  front_side (Axis): The axis that passes through the *front side* of
174
131
  the hub.
175
- broadcast_channel:
176
- Channel number (0 to 255) used to broadcast data.
177
- Choose ``None`` when not using broadcasting.
178
- observe_channels:
179
- A list of channels to listen to when ``hub.ble.observe()`` is
180
- called. Listening to more channels requires more memory.
181
- Default is an empty list (no channels).
182
-
183
- .. versionchanged:: 3.3
184
- Added *broadcast_channel* and *observe_channels* arguments.
185
132
  """
186
133
  pass
187
134
 
@@ -206,16 +153,13 @@ class PrimeHub:
206
153
  speaker = _common.Speaker()
207
154
  imu = _common.IMU()
208
155
  system = _common.System()
209
- ble = _common.BLE()
210
156
 
211
157
  def __init__(
212
158
  self,
213
159
  top_side: Axis = Axis.Z,
214
160
  front_side: Axis = Axis.X,
215
- broadcast_channel: int = None,
216
- observe_channels: Sequence[int] = [],
217
161
  ):
218
- """PrimeHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=None, observe_channels=[])
162
+ """PrimeHub(top_side=Axis.Z, front_side=Axis.X)
219
163
 
220
164
  Initializes the hub. Optionally, specify how the hub is
221
165
  :ref:`placed in your design <robotframe>` by saying in which
@@ -227,16 +171,6 @@ class PrimeHub:
227
171
  the hub.
228
172
  front_side (Axis): The axis that passes through the *front side* of
229
173
  the hub.
230
- broadcast_channel:
231
- Channel number (0 to 255) used to broadcast data.
232
- Choose ``None`` when not using broadcasting.
233
- observe_channels:
234
- A list of channels to listen to when ``hub.ble.observe()`` is
235
- called. Listening to more channels requires more memory.
236
- Default is an empty list (no channels).
237
-
238
- .. versionchanged:: 3.3
239
- Added *broadcast_channel* and *observe_channels* arguments.
240
174
  """
241
175
 
242
176