mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-14 10:35:53 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61d18ebe6f | ||
|
|
ff0b767e3e | ||
|
|
3274cef849 | ||
|
|
b4ff3af36d | ||
|
|
8e5891d9e8 | ||
|
|
7de67852f7 | ||
|
|
31d3a117d6 | ||
|
|
263fe3a1cb |
@@ -20,19 +20,11 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: [3.8, 3.9]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install poetry
|
pip install poetry
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# .readthedocs.yaml
|
||||||
|
# Read the Docs configuration file
|
||||||
|
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||||
|
|
||||||
|
# Required
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
build:
|
||||||
|
os: "ubuntu-22.04"
|
||||||
|
tools:
|
||||||
|
python: "3.10"
|
||||||
|
jobs:
|
||||||
|
post_create_environment:
|
||||||
|
- pip install poetry
|
||||||
|
- poetry config virtualenvs.create false
|
||||||
|
post_install:
|
||||||
|
- poetry install --only=doc
|
||||||
|
|
||||||
|
# Build documentation in the doc/main/ directory with Sphinx
|
||||||
|
sphinx:
|
||||||
|
configuration: doc/main/conf.py
|
||||||
|
fail_on_warning: true
|
||||||
|
|
||||||
|
# Optionally build your docs in additional formats such as PDF
|
||||||
|
formats:
|
||||||
|
- pdf
|
||||||
Vendored
+2
-1
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
// List of extensions which should be recommended for users of this workspace.
|
// List of extensions which should be recommended for users of this workspace.
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"ms-python.python"
|
"ms-python.python",
|
||||||
|
"ms-python.black-formatter"
|
||||||
],
|
],
|
||||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||||
"unwantedRecommendations": [
|
"unwantedRecommendations": [
|
||||||
|
|||||||
Vendored
+2
-2
@@ -4,14 +4,14 @@
|
|||||||
},
|
},
|
||||||
"python.defaultInterpreterPath": ".venv/bin/python",
|
"python.defaultInterpreterPath": ".venv/bin/python",
|
||||||
"python.autoComplete.extraPaths": ["jedi/src"],
|
"python.autoComplete.extraPaths": ["jedi/src"],
|
||||||
"python.formatting.provider": "black",
|
"python.formatting.provider": "none",
|
||||||
"python.linting.pylintEnabled": false,
|
"python.linting.pylintEnabled": false,
|
||||||
"python.linting.flake8Enabled": true,
|
"python.linting.flake8Enabled": true,
|
||||||
"python.linting.pycodestyleEnabled": false,
|
"python.linting.pycodestyleEnabled": false,
|
||||||
"python.linting.enabled": true,
|
"python.linting.enabled": true,
|
||||||
"[python]": {
|
"[python]": {
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.defaultFormatter": "ms-python.python"
|
"editor.defaultFormatter": "ms-python.black-formatter"
|
||||||
},
|
},
|
||||||
"python.languageServer": "Pylance",
|
"python.languageServer": "Pylance",
|
||||||
"python.testing.pytestArgs": [
|
"python.testing.pytestArgs": [
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## 3.3.0b5 - 2023-05-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Documented new `hub.ble` methods.
|
||||||
|
|
||||||
## 3.3.0b4 - 2023-04-21
|
## 3.3.0b4 - 2023-04-21
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
+2
-1
@@ -321,10 +321,11 @@ def on_missing_reference(
|
|||||||
app.builder, node["refdoc"], "signaltypes", "numbers", contnode
|
app.builder, node["refdoc"], "signaltypes", "numbers", contnode
|
||||||
)
|
)
|
||||||
|
|
||||||
# References with special characters can't exist, so we have to supress
|
# References with special characters can't exist, so we have to suppress
|
||||||
# warnings when Sphinx tries to cross reference units like deg/s. For
|
# warnings when Sphinx tries to cross reference units like deg/s. For
|
||||||
# consistency, we also treat units without special characters this way.
|
# consistency, we also treat units without special characters this way.
|
||||||
for unit in [
|
for unit in [
|
||||||
|
"dBm",
|
||||||
"deg",
|
"deg",
|
||||||
"deg/s",
|
"deg/s",
|
||||||
"deg/s²",
|
"deg/s²",
|
||||||
|
|||||||
+3
-3
@@ -8,7 +8,7 @@ import sys
|
|||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = "pybricks"
|
project = "pybricks"
|
||||||
copyright = "2018-2021 The Pybricks Authors"
|
copyright = "2018-2023 The Pybricks Authors"
|
||||||
author = ""
|
author = ""
|
||||||
|
|
||||||
_TITLE = "Pybricks Modules and Examples"
|
_TITLE = "Pybricks Modules and Examples"
|
||||||
@@ -29,7 +29,7 @@ if os.environ.get("READTHEDOCS", None) == "True":
|
|||||||
# HACK: this allows Number type alias to be imported by Sphinx
|
# HACK: this allows Number type alias to be imported by Sphinx
|
||||||
os.environ["SPHINX_BUILD"] = "True"
|
os.environ["SPHINX_BUILD"] = "True"
|
||||||
|
|
||||||
# Addtional configuration of the IDE docs
|
# Additional configuration of the IDE docs
|
||||||
if "ide" in tags.tags: # noqa F821
|
if "ide" in tags.tags: # noqa F821
|
||||||
_DISCLAIMER = ""
|
_DISCLAIMER = ""
|
||||||
html_show_copyright = False
|
html_show_copyright = False
|
||||||
@@ -45,7 +45,7 @@ if "ide" in tags.tags: # noqa F821
|
|||||||
|
|
||||||
exec(open(os.path.abspath("../common/conf.py")).read())
|
exec(open(os.path.abspath("../common/conf.py")).read())
|
||||||
|
|
||||||
# Addtional configuration of the IDE docs
|
# Additional configuration of the IDE docs
|
||||||
if "ide" in tags.tags: # noqa F821
|
if "ide" in tags.tags: # noqa F821
|
||||||
|
|
||||||
extensions.remove("sphinx.ext.mathjax") # noqa F821
|
extensions.remove("sphinx.ext.mathjax") # noqa F821
|
||||||
|
|||||||
@@ -19,6 +19,17 @@ City Hub
|
|||||||
|
|
||||||
.. automethod:: pybricks.hubs::CityHub.light.animate
|
.. automethod:: pybricks.hubs::CityHub.light.animate
|
||||||
|
|
||||||
|
.. rubric:: Using connectionless Bluetooth messaging
|
||||||
|
|
||||||
|
``ble.broadcast()`` does not work on ``CityHub`` due to a bug in the
|
||||||
|
Bluetooth chip firmware.
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::CityHub.ble.observe
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::CityHub.ble.signal_strength
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::CityHub.ble.version
|
||||||
|
|
||||||
.. rubric:: Using the battery
|
.. rubric:: Using the battery
|
||||||
|
|
||||||
.. automethod:: pybricks.hubs::CityHub.battery.voltage
|
.. automethod:: pybricks.hubs::CityHub.battery.voltage
|
||||||
@@ -70,6 +81,17 @@ Creating light animations
|
|||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
../../../examples/pup/hub_common/build/light_animate_cityhub.py
|
../../../examples/pup/hub_common/build/light_animate_cityhub.py
|
||||||
|
|
||||||
|
|
||||||
|
Bluetooth examples
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Observing data from other hubs
|
||||||
|
******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_observe_cityhub.py
|
||||||
|
|
||||||
|
|
||||||
Button and system examples
|
Button and system examples
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,16 @@ Essential Hub
|
|||||||
|
|
||||||
.. automethod:: pybricks.hubs::EssentialHub.imu.settings
|
.. automethod:: pybricks.hubs::EssentialHub.imu.settings
|
||||||
|
|
||||||
|
.. rubric:: Using connectionless Bluetooth messaging
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::EssentialHub.ble.broadcast
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::EssentialHub.ble.observe
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::EssentialHub.ble.signal_strength
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::EssentialHub.ble.version
|
||||||
|
|
||||||
.. rubric:: Using the battery
|
.. rubric:: Using the battery
|
||||||
|
|
||||||
.. automethod:: pybricks.hubs::EssentialHub.battery.voltage
|
.. automethod:: pybricks.hubs::EssentialHub.battery.voltage
|
||||||
@@ -136,6 +146,23 @@ Reading acceleration and angular velocity on one axis
|
|||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
../../../examples/pup/hub_common/build/imu_read_scalar_essentialhub.py
|
../../../examples/pup/hub_common/build/imu_read_scalar_essentialhub.py
|
||||||
|
|
||||||
|
|
||||||
|
Bluetooth examples
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Broadcasting data to other hubs
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_broadcast_essentialhub.py
|
||||||
|
|
||||||
|
Observing data from other hubs
|
||||||
|
******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_observe_essentialhub.py
|
||||||
|
|
||||||
|
|
||||||
System examples
|
System examples
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,16 @@ Move Hub
|
|||||||
|
|
||||||
Changed acceleration units from m/s² to mm/s².
|
Changed acceleration units from m/s² to mm/s².
|
||||||
|
|
||||||
|
.. rubric:: Using connectionless Bluetooth messaging
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::MoveHub.ble.broadcast
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::MoveHub.ble.observe
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::MoveHub.ble.signal_strength
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::MoveHub.ble.version
|
||||||
|
|
||||||
.. rubric:: Using the battery
|
.. rubric:: Using the battery
|
||||||
|
|
||||||
.. automethod:: pybricks.hubs::MoveHub.battery.voltage
|
.. automethod:: pybricks.hubs::MoveHub.battery.voltage
|
||||||
@@ -85,6 +95,23 @@ Reading acceleration
|
|||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
../../../examples/pup/hub_movehub/imu_read_acceleration.py
|
../../../examples/pup/hub_movehub/imu_read_acceleration.py
|
||||||
|
|
||||||
|
|
||||||
|
Bluetooth examples
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Broadcasting data to other hubs
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_broadcast_movehub.py
|
||||||
|
|
||||||
|
Observing data from other hubs
|
||||||
|
******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_observe_movehub.py
|
||||||
|
|
||||||
|
|
||||||
Button and system examples
|
Button and system examples
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,16 @@ Prime Hub / Inventor Hub
|
|||||||
|
|
||||||
.. automethod:: pybricks.hubs::PrimeHub.speaker.play_notes
|
.. automethod:: pybricks.hubs::PrimeHub.speaker.play_notes
|
||||||
|
|
||||||
|
.. rubric:: Using connectionless Bluetooth messaging
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::PrimeHub.ble.broadcast
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::PrimeHub.ble.observe
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::PrimeHub.ble.signal_strength
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::PrimeHub.ble.version
|
||||||
|
|
||||||
.. rubric:: Using the battery
|
.. rubric:: Using the battery
|
||||||
|
|
||||||
.. automethod:: pybricks.hubs::PrimeHub.battery.voltage
|
.. automethod:: pybricks.hubs::PrimeHub.battery.voltage
|
||||||
@@ -247,6 +257,23 @@ Reading acceleration and angular velocity on one axis
|
|||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
../../../examples/pup/hub_common/build/imu_read_scalar_primehub.py
|
../../../examples/pup/hub_common/build/imu_read_scalar_primehub.py
|
||||||
|
|
||||||
|
|
||||||
|
Bluetooth examples
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Broadcasting data to other hubs
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_broadcast_primehub.py
|
||||||
|
|
||||||
|
Observing data from other hubs
|
||||||
|
******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_observe_primehub.py
|
||||||
|
|
||||||
|
|
||||||
System examples
|
System examples
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,16 @@ Technic Hub
|
|||||||
|
|
||||||
.. automethod:: pybricks.hubs::TechnicHub.imu.settings
|
.. automethod:: pybricks.hubs::TechnicHub.imu.settings
|
||||||
|
|
||||||
|
.. rubric:: Using connectionless Bluetooth messaging
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::TechnicHub.ble.broadcast
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::TechnicHub.ble.observe
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::TechnicHub.ble.signal_strength
|
||||||
|
|
||||||
|
.. automethod:: pybricks.hubs::TechnicHub.ble.version
|
||||||
|
|
||||||
.. rubric:: Using the battery
|
.. rubric:: Using the battery
|
||||||
|
|
||||||
.. automethod:: pybricks.hubs::TechnicHub.battery.voltage
|
.. automethod:: pybricks.hubs::TechnicHub.battery.voltage
|
||||||
@@ -128,6 +138,23 @@ Reading acceleration and angular velocity on one axis
|
|||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
../../../examples/pup/hub_common/build/imu_read_scalar_technichub.py
|
../../../examples/pup/hub_common/build/imu_read_scalar_technichub.py
|
||||||
|
|
||||||
|
|
||||||
|
Bluetooth examples
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Broadcasting data to other hubs
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_broadcast_technichub.py
|
||||||
|
|
||||||
|
Observing data from other hubs
|
||||||
|
******************************
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../../examples/pup/hub_common/build/ble_observe_technichub.py
|
||||||
|
|
||||||
|
|
||||||
Button and system examples
|
Button and system examples
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ Powers and logarithms
|
|||||||
|
|
||||||
.. autofunction:: umath.sqrt
|
.. autofunction:: umath.sqrt
|
||||||
|
|
||||||
Trigonomety
|
Trigonometry
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
.. autodata:: umath.pi
|
.. autodata:: umath.pi
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ Driving straight and turning in place
|
|||||||
|
|
||||||
The following program shows the basics of driving and turning.
|
The following program shows the basics of driving and turning.
|
||||||
|
|
||||||
To use the built-in gyro, just replace the two occurences of
|
To use the built-in gyro, just replace the two occurrences of
|
||||||
:class:`DriveBase` with :class:`GyroDriveBase`.
|
:class:`DriveBase` with :class:`GyroDriveBase`.
|
||||||
|
|
||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ For example, you can choose the frequency of a beep to change the pitch.
|
|||||||
temperature: °C
|
temperature: °C
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Temperature is measured in degrees Celcius (°C). To convert to degrees
|
Temperature is measured in degrees Celsius (°C). To convert to degrees
|
||||||
Fahrenheit (°F) or Kelvin (K), you can use the following conversion formulas:
|
Fahrenheit (°F) or Kelvin (K), you can use the following conversion formulas:
|
||||||
|
|
||||||
:math:`^{\circ}\kern1pt\!F =\kern1pt^{\circ}\kern1pt\!C \cdot \frac{9}{5} + 32`.
|
:math:`^{\circ}\kern1pt\!F =\kern1pt^{\circ}\kern1pt\!C \cdot \frac{9}{5} + 32`.
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class ThreadingRFCOMMServer(ThreadingMixIn, RFCOMMServer):
|
|||||||
"""
|
"""
|
||||||
Version of :class:`RFCOMMServer` that handles connections in a new thread.
|
Version of :class:`RFCOMMServer` that handles connections in a new thread.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
daemon_threads = True
|
daemon_threads = True
|
||||||
|
|
||||||
|
|
||||||
@@ -103,4 +104,5 @@ class ThreadingRFCOMMClient(ThreadingMixIn, RFCOMMClient):
|
|||||||
"""
|
"""
|
||||||
Version of :class:`RFCOMMClient` that handles connections in a new thread.
|
Version of :class:`RFCOMMClient` that handles connections in a new thread.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
daemon_threads = True
|
daemon_threads = True
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class BluetoothMailboxServer(MailboxHandlerMixIn, ThreadingRFCOMMServer):
|
|||||||
EV3.
|
EV3.
|
||||||
|
|
||||||
The remote EV3 can either be running MicroPython or the standard EV3
|
The remote EV3 can either be running MicroPython or the standard EV3
|
||||||
firmare.
|
firmware.
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
super(ThreadingRFCOMMServer, self).__init__(
|
super(ThreadingRFCOMMServer, self).__init__(
|
||||||
@@ -304,7 +304,7 @@ class BluetoothMailboxClient(MailboxHandlerMixIn):
|
|||||||
remote EV3s.
|
remote EV3s.
|
||||||
|
|
||||||
The remote EV3s can either be running MicroPython or the standard EV3
|
The remote EV3s can either be running MicroPython or the standard EV3
|
||||||
firmare.
|
firmware.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ def scale(val, src, dst):
|
|||||||
|
|
||||||
|
|
||||||
# Create a loop to react to events
|
# Create a loop to react to events
|
||||||
# This loop reacte to all main PS4 button and stick events. I have left out
|
# This loop reacts to all main PS4 button and stick events. I have left out
|
||||||
# buttons like share and options, but can easily be added in by referring
|
# buttons like share and options, but can easily be added in by referring
|
||||||
# to the table at: https://github.com/codeadamca/python-connect-ps4
|
# to the table at: https://github.com/codeadamca/python-connect-ps4
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
|
||||||
|
from pybricks.hubs import ThisHub
|
||||||
|
from pybricks.pupdevices import Motor
|
||||||
|
from pybricks.parameters import Port
|
||||||
|
from pybricks.tools import wait
|
||||||
|
|
||||||
|
# Initialize the hub.
|
||||||
|
hub = ThisHub(broadcast_channel=1)
|
||||||
|
|
||||||
|
# Initialize the motors.
|
||||||
|
left_motor = Motor(Port.A)
|
||||||
|
right_motor = Motor(Port.B)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# Read the motor angles to be sent to the other hub.
|
||||||
|
left_angle = left_motor.angle()
|
||||||
|
right_angle = right_motor.angle()
|
||||||
|
|
||||||
|
# Set the broadcast data and start broadcasting if not already doing so.
|
||||||
|
hub.ble.broadcast(left_angle, right_angle)
|
||||||
|
|
||||||
|
# Broadcasts are only sent every 100 milliseconds, so there is no reason
|
||||||
|
# to call the broadcast() method more often than that.
|
||||||
|
wait(100)
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
|
||||||
|
from pybricks.hubs import ThisHub
|
||||||
|
from pybricks.pupdevices import Motor
|
||||||
|
from pybricks.parameters import Color, Port
|
||||||
|
from pybricks.tools import wait
|
||||||
|
|
||||||
|
# Initialize the hub.
|
||||||
|
hub = ThisHub(observe_channels=[1])
|
||||||
|
|
||||||
|
# Initialize the motors.
|
||||||
|
left_motor = Motor(Port.A)
|
||||||
|
right_motor = Motor(Port.B)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# Receive broadcast from the other hub.
|
||||||
|
|
||||||
|
data = hub.ble.observe(1)
|
||||||
|
|
||||||
|
if data is None:
|
||||||
|
# No data has been received in the last 1 second.
|
||||||
|
hub.light.on(Color.RED)
|
||||||
|
else:
|
||||||
|
# Data was received and is less that one second old.
|
||||||
|
hub.light.on(Color.GREEN)
|
||||||
|
|
||||||
|
# *data* contains the same values in the same order
|
||||||
|
# that were passed to hub.ble.broadcast() on the
|
||||||
|
# other hub.
|
||||||
|
left_angle = data[0]
|
||||||
|
right_angle = data[1]
|
||||||
|
|
||||||
|
# Make the motors on this hub mirror the position of the
|
||||||
|
# motors on the other hub.
|
||||||
|
left_motor.track_target(left_angle)
|
||||||
|
right_motor.track_target(right_angle)
|
||||||
|
|
||||||
|
# Broadcasts are only sent every 100 milliseconds, so there is
|
||||||
|
# no reason to call the observe() method more often than that.
|
||||||
|
wait(100)
|
||||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
|||||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||||
assert [c["insertText"] for c in completions] == [
|
assert [c["insertText"] for c in completions] == [
|
||||||
"battery",
|
"battery",
|
||||||
|
"ble",
|
||||||
"button",
|
"button",
|
||||||
"light",
|
"light",
|
||||||
"system",
|
"system",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
|||||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||||
assert [c["insertText"] for c in completions] == [
|
assert [c["insertText"] for c in completions] == [
|
||||||
"battery",
|
"battery",
|
||||||
|
"ble",
|
||||||
"button",
|
"button",
|
||||||
"charger",
|
"charger",
|
||||||
"imu",
|
"imu",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
|||||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||||
assert [c["insertText"] for c in completions] == [
|
assert [c["insertText"] for c in completions] == [
|
||||||
"battery",
|
"battery",
|
||||||
|
"ble",
|
||||||
"button",
|
"button",
|
||||||
"imu",
|
"imu",
|
||||||
"light",
|
"light",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
|||||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||||
assert [c["insertText"] for c in completions] == [
|
assert [c["insertText"] for c in completions] == [
|
||||||
"battery",
|
"battery",
|
||||||
|
"ble",
|
||||||
"buttons",
|
"buttons",
|
||||||
"charger",
|
"charger",
|
||||||
"display",
|
"display",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
|||||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||||
assert [c["insertText"] for c in completions] == [
|
assert [c["insertText"] for c in completions] == [
|
||||||
"battery",
|
"battery",
|
||||||
|
"ble",
|
||||||
"button",
|
"button",
|
||||||
"imu",
|
"imu",
|
||||||
"light",
|
"light",
|
||||||
|
|||||||
@@ -78,17 +78,51 @@ def _get_constructor_signature(module: str, type: str) -> SignatureHelp:
|
|||||||
|
|
||||||
|
|
||||||
CONSTRUCTOR_PARAMS = [
|
CONSTRUCTOR_PARAMS = [
|
||||||
pytest.param("pybricks.hubs", "MoveHub", [[]]),
|
pytest.param(
|
||||||
pytest.param("pybricks.hubs", "CityHub", [[]]),
|
"pybricks.hubs",
|
||||||
|
"MoveHub",
|
||||||
|
[["broadcast_channel: int=0", "observe_channels: Sequence[int]=[]"]],
|
||||||
|
),
|
||||||
|
pytest.param(
|
||||||
|
"pybricks.hubs",
|
||||||
|
"CityHub",
|
||||||
|
[["broadcast_channel: int=0", "observe_channels: Sequence[int]=[]"]],
|
||||||
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
"pybricks.hubs",
|
"pybricks.hubs",
|
||||||
"TechnicHub",
|
"TechnicHub",
|
||||||
[["top_side: Axis=Axis.Z", "front_side: Axis=Axis.X"]],
|
[
|
||||||
|
[
|
||||||
|
"top_side: Axis=Axis.Z",
|
||||||
|
"front_side: Axis=Axis.X",
|
||||||
|
"broadcast_channel: int=0",
|
||||||
|
"observe_channels: Sequence[int]=[]",
|
||||||
|
]
|
||||||
|
],
|
||||||
),
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
"pybricks.hubs",
|
"pybricks.hubs",
|
||||||
"PrimeHub",
|
"PrimeHub",
|
||||||
[["top_side: Axis=Axis.Z", "front_side: Axis=Axis.X"]],
|
[
|
||||||
|
[
|
||||||
|
"top_side: Axis=Axis.Z",
|
||||||
|
"front_side: Axis=Axis.X",
|
||||||
|
"broadcast_channel: int=0",
|
||||||
|
"observe_channels: Sequence[int]=[]",
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
|
pytest.param(
|
||||||
|
"pybricks.hubs",
|
||||||
|
"EssentialHub",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"top_side: Axis=Axis.Z",
|
||||||
|
"front_side: Axis=Axis.X",
|
||||||
|
"broadcast_channel: int=0",
|
||||||
|
"observe_channels: Sequence[int]=[]",
|
||||||
|
]
|
||||||
|
],
|
||||||
),
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
"pybricks.pupdevices",
|
"pybricks.pupdevices",
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||||
|
|
||||||
|
## 2.9.0 - 2023-05-16
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated docs to v3.3.0b5.
|
||||||
|
|
||||||
## 2.8.0 - 2023-04-21
|
## 2.8.0 - 2023-04-21
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018-2021 The Pybricks Authors
|
Copyright (c) 2018-2023 The Pybricks Authors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pybricks/ide-docs",
|
"name": "@pybricks/ide-docs",
|
||||||
"version": "2.8.0",
|
"version": "2.9.0",
|
||||||
"description": "Special build of Pybricks API docs for embedding in an IDE.",
|
"description": "Special build of Pybricks API docs for embedding in an IDE.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## 1.8.0 - 2023-04-21
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated `pybricks_jedi` Python package to v1.8.0.
|
||||||
|
|
||||||
## 1.7.0 - 2022-12-28
|
## 1.7.0 - 2022-12-28
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
+3
-3
@@ -12,7 +12,7 @@ BUILD_DIR = (pathlib.Path(__file__).parent / "build").resolve()
|
|||||||
|
|
||||||
package_json = {
|
package_json = {
|
||||||
"name": "@pybricks/jedi",
|
"name": "@pybricks/jedi",
|
||||||
"version": "1.7.0",
|
"version": "1.8.0",
|
||||||
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
|
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -30,7 +30,7 @@ whl_map: dict[str, str] = {}
|
|||||||
shutil.rmtree(BUILD_DIR, True)
|
shutil.rmtree(BUILD_DIR, True)
|
||||||
BUILD_DIR.mkdir()
|
BUILD_DIR.mkdir()
|
||||||
|
|
||||||
# download package and depedencies (*.whl files)
|
# download package and dependencies (*.whl files)
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
sys.executable,
|
sys.executable,
|
||||||
@@ -38,7 +38,7 @@ subprocess.check_call(
|
|||||||
"pip",
|
"pip",
|
||||||
"download",
|
"download",
|
||||||
"--only-binary=any",
|
"--only-binary=any",
|
||||||
"pybricks-jedi==1.7.0",
|
"pybricks-jedi==1.8.0",
|
||||||
],
|
],
|
||||||
cwd=BUILD_DIR,
|
cwd=BUILD_DIR,
|
||||||
)
|
)
|
||||||
|
|||||||
Generated
+540
-540
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pybricks"
|
name = "pybricks"
|
||||||
version = "3.3.0a4"
|
version = "3.3.0a5"
|
||||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||||
authors = ["The Pybricks Authors <dev@pybricks.com>"]
|
authors = ["The Pybricks Authors <dev@pybricks.com>"]
|
||||||
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
|
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
|
||||||
@@ -29,10 +29,12 @@ packages = [
|
|||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.8"
|
python = "^3.8"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.group.lint.dependencies]
|
||||||
black = "^22.3.0"
|
black = "^22.3.0"
|
||||||
doc8 = "^0.8.1"
|
doc8 = "^0.8.1"
|
||||||
flake8 = "^4.0"
|
flake8 = "^4.0"
|
||||||
|
|
||||||
|
[tool.poetry.group.doc.dependencies]
|
||||||
Sphinx = { git = "https://github.com/pybricks/sphinx.git", rev = "b00124cb" }
|
Sphinx = { git = "https://github.com/pybricks/sphinx.git", rev = "b00124cb" }
|
||||||
sphinx-rtd-theme = "^1.0.0"
|
sphinx-rtd-theme = "^1.0.0"
|
||||||
toml = "^0.10.0"
|
toml = "^0.10.0"
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# This file is strictly for building docs on readthedocs.org
|
|
||||||
# See pyproject.toml for local development
|
|
||||||
git+https://github.com/pybricks/sphinx@b00124c#egg=Sphinx
|
|
||||||
sphinx-rtd-theme==1.0.0
|
|
||||||
toml
|
|
||||||
+77
-1
@@ -1,5 +1,5 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
# Copyright (c) 2018-2021 The Pybricks Authors
|
# Copyright (c) 2018-2023 The Pybricks Authors
|
||||||
|
|
||||||
"""Generic cross-platform module for typical devices like lights, displays,
|
"""Generic cross-platform module for typical devices like lights, displays,
|
||||||
speakers, and batteries."""
|
speakers, and batteries."""
|
||||||
@@ -1285,3 +1285,79 @@ class AmbientColorSensor(CommonColorSensor):
|
|||||||
Measured color. The color is described by a hue (0--359), a
|
Measured color. The color is described by a hue (0--359), a
|
||||||
saturation (0--100), and a brightness value (0--100).
|
saturation (0--100), and a brightness value (0--100).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class BLE:
|
||||||
|
"""
|
||||||
|
Bluetooth Low Energy.
|
||||||
|
|
||||||
|
.. versionadded:: 3.3
|
||||||
|
"""
|
||||||
|
|
||||||
|
def broadcast(self, *args: Union[None, bool, int, float, str, bytes]) -> None:
|
||||||
|
"""broadcast(data0, data1, ...)
|
||||||
|
|
||||||
|
Starts broadcasting the given data values.
|
||||||
|
|
||||||
|
Each value can be any of ``int``, ``float``, ``str`, ``bytes``,
|
||||||
|
``None``, ``True``, or ``False``. The data is broadcasted on the
|
||||||
|
*broadcast_channel* you selected when initializing the hub.
|
||||||
|
|
||||||
|
The total data size is quite limited (26 bytes). ``None``, ``True`` and
|
||||||
|
``False`` take 1 byte each. ``float`` takes 5 bytes. ``int`` takes 2 to
|
||||||
|
5 bytes depending on how big the number is. ``str`` and ``bytes`` take
|
||||||
|
the number of bytes in the object plus one extra byte.
|
||||||
|
|
||||||
|
Params:
|
||||||
|
args: Zero or more values to be broadcast.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.. versionadded:: 3.3
|
||||||
|
"""
|
||||||
|
|
||||||
|
def observe(
|
||||||
|
self, channel: int
|
||||||
|
) -> Optional[Tuple[Union[None, bool, int, float, str, bytes], ...]]:
|
||||||
|
"""observe(channel) -> tuple | None
|
||||||
|
|
||||||
|
Retrieves the last observed data for a given channel.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
channel (int): The channel to observe (0 to 255).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A tuple of the received data or ``None`` if no recent data is
|
||||||
|
available.
|
||||||
|
|
||||||
|
.. tip:: Receiving data is more reliable when the hub is not connected
|
||||||
|
to a computer or other devices at the same time.
|
||||||
|
|
||||||
|
.. versionadded:: 3.3
|
||||||
|
"""
|
||||||
|
|
||||||
|
def signal_strength(self, channel: int) -> int:
|
||||||
|
"""signal_strength(channel) -> int: dBm
|
||||||
|
|
||||||
|
Gets the average signal strength in dBm for the given channel.
|
||||||
|
|
||||||
|
This is useful for detecting how near the broadcasting device is. A close
|
||||||
|
device may have a signal strength around -40 dBm while a far away device
|
||||||
|
might have a signal strength around -70 dBm.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
channel (int): The channel number (0 to 255).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The signal strength or ``-128`` if there is no recent observed data.
|
||||||
|
|
||||||
|
.. versionadded:: 3.3
|
||||||
|
"""
|
||||||
|
|
||||||
|
def version(self) -> str:
|
||||||
|
"""version() -> str
|
||||||
|
|
||||||
|
Gets the firmware version from the Bluetooth chip.
|
||||||
|
|
||||||
|
.. versionadded:: 3.3
|
||||||
|
"""
|
||||||
|
|||||||
+99
-7
@@ -1,7 +1,10 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
# Copyright (c) 2018-2022 The Pybricks Authors
|
# Copyright (c) 2018-2023 The Pybricks Authors
|
||||||
|
|
||||||
"""LEGO® Programmable Hubs."""
|
"""LEGO® Programmable Hubs."""
|
||||||
|
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
from . import _common
|
from . import _common
|
||||||
from .ev3dev import _speaker
|
from .ev3dev import _speaker
|
||||||
from .media.ev3dev import Image as _Image
|
from .media.ev3dev import Image as _Image
|
||||||
@@ -38,6 +41,25 @@ class MoveHub:
|
|||||||
imu = _common.SimpleAccelerometer()
|
imu = _common.SimpleAccelerometer()
|
||||||
system = _common.System()
|
system = _common.System()
|
||||||
button = _common.Keypad([_Button.CENTER])
|
button = _common.Keypad([_Button.CENTER])
|
||||||
|
ble = _common.BLE()
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, broadcast_channel: int = 0, observe_channels: Sequence[int] = []
|
||||||
|
):
|
||||||
|
"""MoveHub(broadcast_channel=0, observe_channels=[])
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
broadcast_channel:
|
||||||
|
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||||
|
will use. Default is channel 0.
|
||||||
|
observe_channels:
|
||||||
|
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||||
|
called. Listening to more channels requires more memory.
|
||||||
|
Default is an empty list (no channels).
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added *broadcast_channel* and *observe_channels* arguments.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class CityHub:
|
class CityHub:
|
||||||
@@ -49,6 +71,25 @@ class CityHub:
|
|||||||
light = _common.ColorLight()
|
light = _common.ColorLight()
|
||||||
system = _common.System()
|
system = _common.System()
|
||||||
button = _common.Keypad([_Button.CENTER])
|
button = _common.Keypad([_Button.CENTER])
|
||||||
|
ble = _common.BLE()
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, broadcast_channel: int = 0, observe_channels: Sequence[int] = []
|
||||||
|
):
|
||||||
|
"""CityHub(broadcast_channel=0, observe_channels=[])
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
broadcast_channel:
|
||||||
|
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||||
|
will use. Default is channel 0.
|
||||||
|
observe_channels:
|
||||||
|
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||||
|
called. Listening to more channels requires more memory.
|
||||||
|
Default is an empty list (no channels).
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added *broadcast_channel* and *observe_channels* arguments.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TechnicHub:
|
class TechnicHub:
|
||||||
@@ -61,9 +102,16 @@ class TechnicHub:
|
|||||||
imu = _common.IMU()
|
imu = _common.IMU()
|
||||||
system = _common.System()
|
system = _common.System()
|
||||||
button = _common.Keypad([_Button.CENTER])
|
button = _common.Keypad([_Button.CENTER])
|
||||||
|
ble = _common.BLE()
|
||||||
|
|
||||||
def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
|
def __init__(
|
||||||
"""TechnicHub(top_side=Axis.Z, front_side=Axis.X)
|
self,
|
||||||
|
top_side: Axis = Axis.Z,
|
||||||
|
front_side: Axis = Axis.X,
|
||||||
|
broadcast_channel: int = 0,
|
||||||
|
observe_channels: Sequence[int] = [],
|
||||||
|
):
|
||||||
|
"""TechnicHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
||||||
|
|
||||||
Initializes the hub. Optionally, specify how the hub is
|
Initializes the hub. Optionally, specify how the hub is
|
||||||
:ref:`placed in your design <robotframe>` by saying in which
|
:ref:`placed in your design <robotframe>` by saying in which
|
||||||
@@ -75,6 +123,16 @@ class TechnicHub:
|
|||||||
the hub.
|
the hub.
|
||||||
front_side (Axis): The axis that passes through the *front side* of
|
front_side (Axis): The axis that passes through the *front side* of
|
||||||
the hub.
|
the hub.
|
||||||
|
broadcast_channel:
|
||||||
|
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||||
|
will use. Default is channel 0.
|
||||||
|
observe_channels:
|
||||||
|
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||||
|
called. Listening to more channels requires more memory.
|
||||||
|
Default is an empty list (no channels).
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added *broadcast_channel* and *observe_channels* arguments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -89,9 +147,16 @@ class EssentialHub:
|
|||||||
light = _common.ColorLight()
|
light = _common.ColorLight()
|
||||||
imu = _common.IMU()
|
imu = _common.IMU()
|
||||||
system = _common.System()
|
system = _common.System()
|
||||||
|
ble = _common.BLE()
|
||||||
|
|
||||||
def __init__(self, top_side=Axis.Z, front_side=Axis.X):
|
def __init__(
|
||||||
"""__init__(top_side=Axis.Z, front_side=Axis.X)
|
self,
|
||||||
|
top_side: Axis = Axis.Z,
|
||||||
|
front_side: Axis = Axis.X,
|
||||||
|
broadcast_channel: int = 0,
|
||||||
|
observe_channels: Sequence[int] = [],
|
||||||
|
):
|
||||||
|
"""EssentialHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
||||||
|
|
||||||
Initializes the hub. Optionally, specify how the hub is
|
Initializes the hub. Optionally, specify how the hub is
|
||||||
:ref:`placed in your design <robotframe>` by saying in which
|
:ref:`placed in your design <robotframe>` by saying in which
|
||||||
@@ -103,6 +168,16 @@ class EssentialHub:
|
|||||||
the hub.
|
the hub.
|
||||||
front_side (Axis): The axis that passes through the *front side* of
|
front_side (Axis): The axis that passes through the *front side* of
|
||||||
the hub.
|
the hub.
|
||||||
|
broadcast_channel:
|
||||||
|
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||||
|
will use. Default is channel 0.
|
||||||
|
observe_channels:
|
||||||
|
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||||
|
called. Listening to more channels requires more memory.
|
||||||
|
Default is an empty list (no channels).
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added *broadcast_channel* and *observe_channels* arguments.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -127,9 +202,16 @@ class PrimeHub:
|
|||||||
speaker = _common.Speaker()
|
speaker = _common.Speaker()
|
||||||
imu = _common.IMU()
|
imu = _common.IMU()
|
||||||
system = _common.System()
|
system = _common.System()
|
||||||
|
ble = _common.BLE()
|
||||||
|
|
||||||
def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
|
def __init__(
|
||||||
"""PrimeHub(top_side=Axis.Z, front_side=Axis.X)
|
self,
|
||||||
|
top_side: Axis = Axis.Z,
|
||||||
|
front_side: Axis = Axis.X,
|
||||||
|
broadcast_channel: int = 0,
|
||||||
|
observe_channels: Sequence[int] = [],
|
||||||
|
):
|
||||||
|
"""PrimeHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
||||||
|
|
||||||
Initializes the hub. Optionally, specify how the hub is
|
Initializes the hub. Optionally, specify how the hub is
|
||||||
:ref:`placed in your design <robotframe>` by saying in which
|
:ref:`placed in your design <robotframe>` by saying in which
|
||||||
@@ -141,6 +223,16 @@ class PrimeHub:
|
|||||||
the hub.
|
the hub.
|
||||||
front_side (Axis): The axis that passes through the *front side* of
|
front_side (Axis): The axis that passes through the *front side* of
|
||||||
the hub.
|
the hub.
|
||||||
|
broadcast_channel:
|
||||||
|
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||||
|
will use. Default is channel 0.
|
||||||
|
observe_channels:
|
||||||
|
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||||
|
called. Listening to more channels requires more memory.
|
||||||
|
Default is an empty list (no channels).
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Added *broadcast_channel* and *observe_channels* arguments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class Remote:
|
|||||||
Button.RIGHT_PLUS,
|
Button.RIGHT_PLUS,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
addresss: Union[str, None]
|
address: Union[str, None]
|
||||||
|
|
||||||
def __init__(self, name: Optional[str] = None, timeout: int = 10000):
|
def __init__(self, name: Optional[str] = None, timeout: int = 10000):
|
||||||
"""Remote(name=None, timeout=10000)
|
"""Remote(name=None, timeout=10000)
|
||||||
|
|||||||
@@ -1170,7 +1170,7 @@ class str:
|
|||||||
If no argument is given, this creates an empty ``str`` object.
|
If no argument is given, this creates an empty ``str`` object.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
object: If only this argument is given, this returns the stirng
|
object: If only this argument is given, this returns the string
|
||||||
representation of the object.
|
representation of the object.
|
||||||
encoding (str): If the first argument is a ``bytearray`` or ``bytes``
|
encoding (str): If the first argument is a ``bytearray`` or ``bytes``
|
||||||
object and the encoding argument is ``"utf-8"``, this will decode
|
object and the encoding argument is ``"utf-8"``, this will decode
|
||||||
|
|||||||
Reference in New Issue
Block a user