pybricks 3.3.0a4__tar.gz → 3.3.0a5__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 (36) hide show
  1. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/PKG-INFO +1 -1
  2. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/pyproject.toml +4 -2
  3. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/_common.py +77 -1
  4. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/hubs.py +99 -7
  5. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/pupdevices.py +1 -1
  6. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/LICENSE +0 -0
  7. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/README.rst +0 -0
  8. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/micropython/__init__.py +0 -0
  9. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/micropython/py.typed +0 -0
  10. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/__init__.py +0 -0
  11. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/ev3dev/_speaker.py +0 -0
  12. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/ev3devices.py +0 -0
  13. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/iodevices.py +0 -0
  14. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/media/__init__.py +0 -0
  15. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/media/ev3dev.py +0 -0
  16. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/media/py.typed +0 -0
  17. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/messaging.py +0 -0
  18. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/nxtdevices.py +0 -0
  19. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/parameters.py +0 -0
  20. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/py.typed +0 -0
  21. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/robotics.py +0 -0
  22. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/pybricks/tools.py +0 -0
  23. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/uerrno/__init__.py +0 -0
  24. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/uerrno/py.typed +0 -0
  25. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/uio/__init__.py +0 -0
  26. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/uio/py.typed +0 -0
  27. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/ujson/__init__.py +0 -0
  28. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/umath/__init__.py +0 -0
  29. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/umath/py.typed +0 -0
  30. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/urandom/__init__.py +0 -0
  31. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/urandom/py.typed +0 -0
  32. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/uselect/__init__.py +0 -0
  33. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/uselect/py.typed +0 -0
  34. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/ustruct/__init__.py +0 -0
  35. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/usys/__init__.py +0 -0
  36. {pybricks-3.3.0a4 → pybricks-3.3.0a5}/src/usys/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybricks
3
- Version: 3.3.0a4
3
+ Version: 3.3.0a5
4
4
  Summary: Documentation and user-API stubs for Pybricks MicroPython
5
5
  Home-page: https://pybricks.com
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pybricks"
3
- version = "3.3.0a4"
3
+ version = "3.3.0a5"
4
4
  description = "Documentation and user-API stubs for Pybricks MicroPython"
5
5
  authors = ["The Pybricks Authors <dev@pybricks.com>"]
6
6
  maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
@@ -29,10 +29,12 @@ packages = [
29
29
  [tool.poetry.dependencies]
30
30
  python = "^3.8"
31
31
 
32
- [tool.poetry.dev-dependencies]
32
+ [tool.poetry.group.lint.dependencies]
33
33
  black = "^22.3.0"
34
34
  doc8 = "^0.8.1"
35
35
  flake8 = "^4.0"
36
+
37
+ [tool.poetry.group.doc.dependencies]
36
38
  Sphinx = { git = "https://github.com/pybricks/sphinx.git", rev = "b00124cb" }
37
39
  sphinx-rtd-theme = "^1.0.0"
38
40
  toml = "^0.10.0"
@@ -1,5 +1,5 @@
1
1
  # SPDX-License-Identifier: MIT
2
- # Copyright (c) 2018-2021 The Pybricks Authors
2
+ # Copyright (c) 2018-2023 The Pybricks Authors
3
3
 
4
4
  """Generic cross-platform module for typical devices like lights, displays,
5
5
  speakers, and batteries."""
@@ -1285,3 +1285,79 @@ class AmbientColorSensor(CommonColorSensor):
1285
1285
  Measured color. The color is described by a hue (0--359), a
1286
1286
  saturation (0--100), and a brightness value (0--100).
1287
1287
  """
1288
+
1289
+
1290
+ class BLE:
1291
+ """
1292
+ Bluetooth Low Energy.
1293
+
1294
+ .. versionadded:: 3.3
1295
+ """
1296
+
1297
+ def broadcast(self, *args: Union[None, bool, int, float, str, bytes]) -> None:
1298
+ """broadcast(data0, data1, ...)
1299
+
1300
+ Starts broadcasting the given data values.
1301
+
1302
+ Each value can be any of ``int``, ``float``, ``str`, ``bytes``,
1303
+ ``None``, ``True``, or ``False``. The data is broadcasted on the
1304
+ *broadcast_channel* you selected when initializing the hub.
1305
+
1306
+ The total data size is quite limited (26 bytes). ``None``, ``True`` and
1307
+ ``False`` take 1 byte each. ``float`` takes 5 bytes. ``int`` takes 2 to
1308
+ 5 bytes depending on how big the number is. ``str`` and ``bytes`` take
1309
+ the number of bytes in the object plus one extra byte.
1310
+
1311
+ Params:
1312
+ args: Zero or more values to be broadcast.
1313
+
1314
+
1315
+
1316
+ .. versionadded:: 3.3
1317
+ """
1318
+
1319
+ def observe(
1320
+ self, channel: int
1321
+ ) -> Optional[Tuple[Union[None, bool, int, float, str, bytes], ...]]:
1322
+ """observe(channel) -> tuple | None
1323
+
1324
+ Retrieves the last observed data for a given channel.
1325
+
1326
+ Args:
1327
+ channel (int): The channel to observe (0 to 255).
1328
+
1329
+ Returns:
1330
+ A tuple of the received data or ``None`` if no recent data is
1331
+ available.
1332
+
1333
+ .. tip:: Receiving data is more reliable when the hub is not connected
1334
+ to a computer or other devices at the same time.
1335
+
1336
+ .. versionadded:: 3.3
1337
+ """
1338
+
1339
+ def signal_strength(self, channel: int) -> int:
1340
+ """signal_strength(channel) -> int: dBm
1341
+
1342
+ Gets the average signal strength in dBm for the given channel.
1343
+
1344
+ This is useful for detecting how near the broadcasting device is. A close
1345
+ device may have a signal strength around -40 dBm while a far away device
1346
+ might have a signal strength around -70 dBm.
1347
+
1348
+ Args:
1349
+ channel (int): The channel number (0 to 255).
1350
+
1351
+ Returns:
1352
+ The signal strength or ``-128`` if there is no recent observed data.
1353
+
1354
+ .. versionadded:: 3.3
1355
+ """
1356
+
1357
+ def version(self) -> str:
1358
+ """version() -> str
1359
+
1360
+ Gets the firmware version from the Bluetooth chip.
1361
+
1362
+ .. versionadded:: 3.3
1363
+ """
@@ -1,7 +1,10 @@
1
1
  # SPDX-License-Identifier: MIT
2
- # Copyright (c) 2018-2022 The Pybricks Authors
2
+ # Copyright (c) 2018-2023 The Pybricks Authors
3
3
 
4
4
  """LEGO® Programmable Hubs."""
5
+
6
+ from typing import Sequence
7
+
5
8
  from . import _common
6
9
  from .ev3dev import _speaker
7
10
  from .media.ev3dev import Image as _Image
@@ -38,6 +41,25 @@ class MoveHub:
38
41
  imu = _common.SimpleAccelerometer()
39
42
  system = _common.System()
40
43
  button = _common.Keypad([_Button.CENTER])
44
+ ble = _common.BLE()
45
+
46
+ def __init__(
47
+ self, broadcast_channel: int = 0, observe_channels: Sequence[int] = []
48
+ ):
49
+ """MoveHub(broadcast_channel=0, observe_channels=[])
50
+
51
+ Arguments:
52
+ broadcast_channel:
53
+ A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
54
+ will use. Default is channel 0.
55
+ observe_channels:
56
+ A list of channels to listen to when ``hub.ble.observe()`` is
57
+ called. Listening to more channels requires more memory.
58
+ Default is an empty list (no channels).
59
+
60
+ .. versionchanged:: 3.3
61
+ Added *broadcast_channel* and *observe_channels* arguments.
62
+ """
41
63
 
42
64
 
43
65
  class CityHub:
@@ -49,6 +71,25 @@ class CityHub:
49
71
  light = _common.ColorLight()
50
72
  system = _common.System()
51
73
  button = _common.Keypad([_Button.CENTER])
74
+ ble = _common.BLE()
75
+
76
+ def __init__(
77
+ self, broadcast_channel: int = 0, observe_channels: Sequence[int] = []
78
+ ):
79
+ """CityHub(broadcast_channel=0, observe_channels=[])
80
+
81
+ Arguments:
82
+ broadcast_channel:
83
+ A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
84
+ will use. Default is channel 0.
85
+ observe_channels:
86
+ A list of channels to listen to when ``hub.ble.observe()`` is
87
+ called. Listening to more channels requires more memory.
88
+ Default is an empty list (no channels).
89
+
90
+ .. versionchanged:: 3.3
91
+ Added *broadcast_channel* and *observe_channels* arguments.
92
+ """
52
93
 
53
94
 
54
95
  class TechnicHub:
@@ -61,9 +102,16 @@ class TechnicHub:
61
102
  imu = _common.IMU()
62
103
  system = _common.System()
63
104
  button = _common.Keypad([_Button.CENTER])
105
+ ble = _common.BLE()
64
106
 
65
- def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
66
- """TechnicHub(top_side=Axis.Z, front_side=Axis.X)
107
+ def __init__(
108
+ self,
109
+ top_side: Axis = Axis.Z,
110
+ front_side: Axis = Axis.X,
111
+ broadcast_channel: int = 0,
112
+ observe_channels: Sequence[int] = [],
113
+ ):
114
+ """TechnicHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
67
115
 
68
116
  Initializes the hub. Optionally, specify how the hub is
69
117
  :ref:`placed in your design <robotframe>` by saying in which
@@ -75,6 +123,16 @@ class TechnicHub:
75
123
  the hub.
76
124
  front_side (Axis): The axis that passes through the *front side* of
77
125
  the hub.
126
+ broadcast_channel:
127
+ A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
128
+ will use. Default is channel 0.
129
+ observe_channels:
130
+ A list of channels to listen to when ``hub.ble.observe()`` is
131
+ called. Listening to more channels requires more memory.
132
+ Default is an empty list (no channels).
133
+
134
+ .. versionchanged:: 3.3
135
+ Added *broadcast_channel* and *observe_channels* arguments.
78
136
  """
79
137
 
80
138
 
@@ -89,9 +147,16 @@ class EssentialHub:
89
147
  light = _common.ColorLight()
90
148
  imu = _common.IMU()
91
149
  system = _common.System()
150
+ ble = _common.BLE()
92
151
 
93
- def __init__(self, top_side=Axis.Z, front_side=Axis.X):
94
- """__init__(top_side=Axis.Z, front_side=Axis.X)
152
+ def __init__(
153
+ self,
154
+ top_side: Axis = Axis.Z,
155
+ front_side: Axis = Axis.X,
156
+ broadcast_channel: int = 0,
157
+ observe_channels: Sequence[int] = [],
158
+ ):
159
+ """EssentialHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
95
160
 
96
161
  Initializes the hub. Optionally, specify how the hub is
97
162
  :ref:`placed in your design <robotframe>` by saying in which
@@ -103,6 +168,16 @@ class EssentialHub:
103
168
  the hub.
104
169
  front_side (Axis): The axis that passes through the *front side* of
105
170
  the hub.
171
+ broadcast_channel:
172
+ A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
173
+ will use. Default is channel 0.
174
+ observe_channels:
175
+ A list of channels to listen to when ``hub.ble.observe()`` is
176
+ called. Listening to more channels requires more memory.
177
+ Default is an empty list (no channels).
178
+
179
+ .. versionchanged:: 3.3
180
+ Added *broadcast_channel* and *observe_channels* arguments.
106
181
  """
107
182
  pass
108
183
 
@@ -127,9 +202,16 @@ class PrimeHub:
127
202
  speaker = _common.Speaker()
128
203
  imu = _common.IMU()
129
204
  system = _common.System()
205
+ ble = _common.BLE()
130
206
 
131
- def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
132
- """PrimeHub(top_side=Axis.Z, front_side=Axis.X)
207
+ def __init__(
208
+ self,
209
+ top_side: Axis = Axis.Z,
210
+ front_side: Axis = Axis.X,
211
+ broadcast_channel: int = 0,
212
+ observe_channels: Sequence[int] = [],
213
+ ):
214
+ """PrimeHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
133
215
 
134
216
  Initializes the hub. Optionally, specify how the hub is
135
217
  :ref:`placed in your design <robotframe>` by saying in which
@@ -141,6 +223,16 @@ class PrimeHub:
141
223
  the hub.
142
224
  front_side (Axis): The axis that passes through the *front side* of
143
225
  the hub.
226
+ broadcast_channel:
227
+ A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
228
+ will use. Default is channel 0.
229
+ observe_channels:
230
+ A list of channels to listen to when ``hub.ble.observe()`` is
231
+ called. Listening to more channels requires more memory.
232
+ Default is an empty list (no channels).
233
+
234
+ .. versionchanged:: 3.3
235
+ Added *broadcast_channel* and *observe_channels* arguments.
144
236
  """
145
237
 
146
238
 
@@ -97,7 +97,7 @@ class Remote:
97
97
  Button.RIGHT_PLUS,
98
98
  )
99
99
  )
100
- addresss: Union[str, None]
100
+ address: Union[str, None]
101
101
 
102
102
  def __init__(self, name: Optional[str] = None, timeout: int = 10000):
103
103
  """Remote(name=None, timeout=10000)
File without changes
File without changes
File without changes
File without changes