pybricks 3.6.1__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.
- {pybricks-3.6.1 → pybricks-4.0.0}/PKG-INFO +5 -2
- {pybricks-3.6.1 → pybricks-4.0.0}/pyproject.toml +1 -1
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/_common.py +6 -95
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/ev3devices.py +4 -4
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/hubs.py +9 -75
- pybricks-4.0.0/src/pybricks/iodevices.py +694 -0
- pybricks-4.0.0/src/pybricks/messaging.py +465 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/parameters.py +22 -9
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/pupdevices.py +221 -23
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/robotics.py +67 -31
- pybricks-3.6.1/src/pybricks/iodevices.py +0 -452
- pybricks-3.6.1/src/pybricks/messaging.py +0 -233
- {pybricks-3.6.1 → pybricks-4.0.0}/AUTHORS.md +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/LICENSE +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/README.rst +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/micropython/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/micropython/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/ev3dev/_speaker.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/media/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/media/ev3dev.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/media/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/nxtdevices.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/pybricks/tools.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/uerrno/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/uerrno/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/uio/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/uio/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/ujson/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/umath/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/umath/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/urandom/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/urandom/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/uselect/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/uselect/py.typed +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/ustruct/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/usys/__init__.py +0 -0
- {pybricks-3.6.1 → pybricks-4.0.0}/src/usys/py.typed +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pybricks
|
|
3
|
-
Version:
|
|
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
|
+
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."""
|
|
@@ -125,10 +127,13 @@ class System:
|
|
|
125
127
|
firmware issue.
|
|
126
128
|
- ``"host_connected_ble"``: ``True`` if the hub is connected to a
|
|
127
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.
|
|
@@ -828,7 +833,7 @@ class LightMatrix:
|
|
|
828
833
|
contents remain unchanged.
|
|
829
834
|
|
|
830
835
|
Arguments:
|
|
831
|
-
|
|
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
|
"""
|
|
@@ -1211,17 +1216,6 @@ class IMU:
|
|
|
1211
1216
|
even as the robot turns more than 180 degrees. It does not wrap around
|
|
1212
1217
|
to -180 like it does in some apps.
|
|
1213
1218
|
|
|
1214
|
-
|
|
1215
|
-
.. note:: *For now, this method only keeps track of the heading while
|
|
1216
|
-
the robot is on a flat surface.*
|
|
1217
|
-
|
|
1218
|
-
This means that the value is
|
|
1219
|
-
no longer correct if you lift it from the table or turn on
|
|
1220
|
-
a ramp. Try ``hub.imu.heading('3D')`` for a heading value
|
|
1221
|
-
that compensates for this. This will become the default in a
|
|
1222
|
-
future release. If you try it, please let us know on our
|
|
1223
|
-
forums!
|
|
1224
|
-
|
|
1225
1219
|
Returns:
|
|
1226
1220
|
Heading angle relative to starting orientation.
|
|
1227
1221
|
|
|
@@ -1439,86 +1433,3 @@ class AmbientColorSensor(CommonColorSensor):
|
|
|
1439
1433
|
Measured color. The color is described by a hue (0--359), a
|
|
1440
1434
|
saturation (0--100), and a brightness value (0--100).
|
|
1441
1435
|
"""
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
class BLE:
|
|
1445
|
-
"""
|
|
1446
|
-
Bluetooth Low Energy.
|
|
1447
|
-
|
|
1448
|
-
.. versionadded:: 3.3
|
|
1449
|
-
"""
|
|
1450
|
-
|
|
1451
|
-
def broadcast(self, data: Union[bool, int, float, str, bytes]) -> MaybeAwaitable:
|
|
1452
|
-
"""broadcast(data)
|
|
1453
|
-
|
|
1454
|
-
Starts broadcasting the given data on
|
|
1455
|
-
the ``broadcast_channel`` you selected when initializing the hub.
|
|
1456
|
-
|
|
1457
|
-
Data may be of type ``int``, ``float``, ``str``, ``bytes``,
|
|
1458
|
-
``True``, or ``False``. It can also be a list or tuple of these.
|
|
1459
|
-
|
|
1460
|
-
Choose ``None`` to stop broadcasting. This helps improve performance
|
|
1461
|
-
when you don't need the broadcast feature, especially when observing
|
|
1462
|
-
at the same time.
|
|
1463
|
-
|
|
1464
|
-
The total data size is quite limited (26 bytes). ``True`` and
|
|
1465
|
-
``False`` take 1 byte each. ``float`` takes 5 bytes. ``int`` takes 2 to
|
|
1466
|
-
5 bytes depending on how big the number is. ``str`` and ``bytes`` take
|
|
1467
|
-
the number of bytes in the object plus one extra byte.
|
|
1468
|
-
|
|
1469
|
-
When multitasking, only one task can broadcast at a time. To broadcast
|
|
1470
|
-
information from multiple tasks (or block stacks), you could use a
|
|
1471
|
-
dedicated separate task that broadcast new values when one or more
|
|
1472
|
-
variables change.
|
|
1473
|
-
|
|
1474
|
-
Args:
|
|
1475
|
-
data: The value or values to be broadcast.
|
|
1476
|
-
|
|
1477
|
-
.. versionadded:: 3.3
|
|
1478
|
-
"""
|
|
1479
|
-
|
|
1480
|
-
def observe(
|
|
1481
|
-
self, channel: int
|
|
1482
|
-
) -> Optional[Tuple[Union[bool, int, float, str, bytes], ...]]:
|
|
1483
|
-
"""observe(channel) -> bool | int | float | str | bytes | tuple | None
|
|
1484
|
-
|
|
1485
|
-
Retrieves the last observed data for a given channel.
|
|
1486
|
-
|
|
1487
|
-
Receiving data is more reliable when the hub is not connected
|
|
1488
|
-
to a computer or other devices at the same time.
|
|
1489
|
-
|
|
1490
|
-
Args:
|
|
1491
|
-
channel (int): The channel to observe (0 to 255).
|
|
1492
|
-
|
|
1493
|
-
Returns:
|
|
1494
|
-
The received data in the same format as it was sent, or ``None``
|
|
1495
|
-
if no recent data is available.
|
|
1496
|
-
|
|
1497
|
-
.. versionadded:: 3.3
|
|
1498
|
-
"""
|
|
1499
|
-
|
|
1500
|
-
def signal_strength(self, channel: int) -> int:
|
|
1501
|
-
"""signal_strength(channel) -> int: dBm
|
|
1502
|
-
|
|
1503
|
-
Gets the average signal strength in dBm for the given channel.
|
|
1504
|
-
|
|
1505
|
-
This indicates how near the broadcasting device is. Nearby devices
|
|
1506
|
-
may have a signal strength around -40 dBm, while far away devices
|
|
1507
|
-
might have a signal strength around -70 dBm.
|
|
1508
|
-
|
|
1509
|
-
Args:
|
|
1510
|
-
channel (int): The channel number (0 to 255).
|
|
1511
|
-
|
|
1512
|
-
Returns:
|
|
1513
|
-
The signal strength or ``-128`` if there is no recent observed data.
|
|
1514
|
-
|
|
1515
|
-
.. versionadded:: 3.3
|
|
1516
|
-
"""
|
|
1517
|
-
|
|
1518
|
-
def version(self) -> str:
|
|
1519
|
-
"""version() -> str
|
|
1520
|
-
|
|
1521
|
-
Gets the firmware version from the Bluetooth chip.
|
|
1522
|
-
|
|
1523
|
-
.. versionadded:: 3.3
|
|
1524
|
-
"""
|
|
@@ -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 ``
|
|
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) ->
|
|
138
|
-
"""buttons(channel) ->
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|