mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-13 10:04:45 +00:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ea780cc9e | ||
|
|
78a8fea78f | ||
|
|
99a7c69ac5 | ||
|
|
1a64ba718f | ||
|
|
6d332deb3f | ||
|
|
a7df6988ab | ||
|
|
a2e17f6889 | ||
|
|
866b50fef6 | ||
|
|
9c7378ce64 | ||
|
|
3b20a811cb | ||
|
|
73cc441edb | ||
|
|
7770a88aa0 | ||
|
|
f06caa32bc | ||
|
|
fb8198fe8f | ||
|
|
3dad15ac11 | ||
|
|
790fcfa66a | ||
|
|
d108d7c163 | ||
|
|
7ce3721b48 | ||
|
|
d0bfbcb4d1 |
@@ -1,7 +1,7 @@
|
||||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
||||
|
||||
name: Python package
|
||||
name: Build Python package and docs
|
||||
|
||||
on: [ push, pull_request ]
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Release to PyPI
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build_and_publish:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
- uses: abatilo/actions-poetry@v2.0.0
|
||||
with:
|
||||
poetry-version: 1.1.6
|
||||
- run: poetry install
|
||||
- run: poetry build
|
||||
- run: poetry publish
|
||||
env:
|
||||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
|
||||
@@ -1,49 +0,0 @@
|
||||
:mod:`geometry <pybricks.geometry>` -- Geometry and algebra
|
||||
============================================================
|
||||
|
||||
.. module:: pybricks.geometry
|
||||
|
||||
.. autoclass:: pybricks.geometry.Matrix
|
||||
:no-members:
|
||||
|
||||
.. autoattribute:: pybricks.geometry::Matrix.T
|
||||
|
||||
.. autoattribute:: pybricks.geometry::Matrix.shape
|
||||
|
||||
.. autofunction:: pybricks.geometry.vector
|
||||
|
||||
.. autoclass:: pybricks.geometry.Axis
|
||||
:no-members:
|
||||
|
||||
.. _robotframe:
|
||||
|
||||
Reference frames
|
||||
-----------------------
|
||||
|
||||
The Pybricks module and this documentation use the following conventions:
|
||||
|
||||
- X: Positive means forward. Negative means backward.
|
||||
- Y: Positive means to the left. Negative means to the right.
|
||||
- Z: Positive means upward. Negative means downward.
|
||||
|
||||
To make sure that all hub measurements (such as acceleration) have the correct
|
||||
value and sign, you can specify how the hub is mounted in your creation. This
|
||||
adjust the measurements so that it is easy to see how your *robot* is moving,
|
||||
rather than how the *hub* is moving.
|
||||
|
||||
For example, the hub may be mounted upside down in your design. If you
|
||||
configure the settings as shown in :numref:`fig_imuexamples`, the hub
|
||||
measurements will be adjusted accordingly. This way, a positive acceleration
|
||||
value in the X direction means that your *robot* accelerates forward, even
|
||||
though the *hub* accelerates backward.
|
||||
|
||||
.. _fig_imuexamples:
|
||||
|
||||
.. figure:: ../api/images/imuexamples_label.png
|
||||
:width: 100 %
|
||||
|
||||
How to configure the ``top_side`` and ``front_side`` settings for three
|
||||
different robot designs. The same technique can be applied to other hubs
|
||||
and other creations, by noting which way the top and
|
||||
front :class:`Side <Side>` of the hub are pointing. The example
|
||||
on the left is the default configuration.
|
||||
@@ -10,7 +10,6 @@
|
||||
movehub
|
||||
cityhub
|
||||
technichub
|
||||
primehub
|
||||
ev3brick
|
||||
|
||||
.. pybricks-classlink:: MoveHub
|
||||
@@ -31,18 +30,6 @@
|
||||
:height: 10 em
|
||||
:target: technichub.html
|
||||
|
||||
.. pybricks-classlink:: PrimeHub
|
||||
|
||||
.. figure:: ../../api/images/primehub.png
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
.. pybricks-classlink:: InventorHub
|
||||
|
||||
.. figure:: ../../api/images/inventorhub.png
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
.. pybricks-classlink:: EV3Brick
|
||||
|
||||
.. figure:: ../../api/images/ev3brick.png
|
||||
|
||||
@@ -19,12 +19,6 @@ Move Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.light.animate
|
||||
|
||||
.. rubric:: Using the IMU
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.imu.up
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.imu.acceleration
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.battery.voltage
|
||||
@@ -46,17 +40,3 @@ Making the light blink
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/light_blink.py
|
||||
|
||||
IMU examples
|
||||
---------------
|
||||
|
||||
Testing which way is up
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/imu_up.py
|
||||
|
||||
Reading acceleration
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/imu_read_acceleration.py
|
||||
|
||||
@@ -1,210 +0,0 @@
|
||||
Prime Hub / Inventor Hub
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. figure:: ../../api/images/primeinventorhub.png
|
||||
:height: 15 em
|
||||
|
||||
.. class:: InventorHub
|
||||
|
||||
This class is the same as the ``PrimeHub`` class, shown below. Both classes
|
||||
work on both hubs.
|
||||
|
||||
These hubs are completely identical. They use the same Pybricks firmware.
|
||||
|
||||
.. autoclass:: pybricks.hubs.PrimeHub
|
||||
:no-members:
|
||||
|
||||
.. rubric:: Using the hub status light
|
||||
|
||||
.. figure:: ../../api/images/primehub_light_label.png
|
||||
:width: 22 em
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.light.on
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.light.off
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.light.blink
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.light.animate
|
||||
|
||||
.. rubric:: Using the light matrix display
|
||||
|
||||
.. figure:: ../../api/images/primehub_display_label.png
|
||||
:width: 22 em
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.orientation
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.off
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.pixel
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.image
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.animate
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.number
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.char
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.text
|
||||
|
||||
.. rubric:: Using the buttons
|
||||
|
||||
.. figure:: ../../api/images/primehub_buttons_label.png
|
||||
:width: 22 em
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.buttons.pressed
|
||||
|
||||
.. rubric:: Using the IMU
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.imu.up
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.imu.tilt
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.imu.acceleration
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.imu.angular_velocity
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.imu.heading
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.imu.reset_heading
|
||||
|
||||
.. rubric:: Using the speaker
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.speaker.beep
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.speaker.play_notes
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.battery.voltage
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.battery.current
|
||||
|
||||
.. note:: The examples below use the ``PrimeHub`` class. The examples work fine
|
||||
on both hubs because they are the identical. If you prefer, you can
|
||||
change this to ``InventorHub``.
|
||||
|
||||
Status light examples
|
||||
---------------------
|
||||
|
||||
Turning the light on and off
|
||||
****************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_off.py
|
||||
|
||||
Changing brightness and using custom colors
|
||||
*******************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_hsv.py
|
||||
|
||||
Making the light blink
|
||||
**********************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_blink.py
|
||||
|
||||
Creating light animations
|
||||
*************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_animate.py
|
||||
|
||||
Matrix display examples
|
||||
-----------------------
|
||||
|
||||
Displaying images
|
||||
*****************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_image.py
|
||||
|
||||
Displaying numbers
|
||||
******************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_number.py
|
||||
|
||||
Displaying text
|
||||
***************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_text.py
|
||||
|
||||
Displaying individual pixels
|
||||
****************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_pixel.py
|
||||
|
||||
Changing the display orientation
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_orientation.py
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_orientation_imu.py
|
||||
|
||||
Making your own images
|
||||
**********************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_matrix.py
|
||||
|
||||
Combining images to make expressions
|
||||
************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_expression.py
|
||||
|
||||
Displaying animations
|
||||
*********************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/display_animate.py
|
||||
|
||||
Button examples
|
||||
---------------
|
||||
|
||||
Detecting button presses
|
||||
************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/button_main.py
|
||||
|
||||
IMU examples
|
||||
---------------
|
||||
|
||||
Testing which way is up
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_up.py
|
||||
|
||||
|
||||
Reading the tilt value
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_tilt.py
|
||||
|
||||
Using a custom hub orientation
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_tilt_blast.py
|
||||
|
||||
Reading acceleration and angular velocity vectors
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_read_vector.py
|
||||
|
||||
Reading acceleration and angular velocity on one axis
|
||||
*****************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_read_scalar.py
|
||||
@@ -4,8 +4,7 @@ Technic Hub
|
||||
.. figure:: ../../api/images/technichub.png
|
||||
:height: 15 em
|
||||
|
||||
.. autoclass:: pybricks.hubs.TechnicHub
|
||||
:no-members:
|
||||
.. class:: TechnicHub
|
||||
|
||||
.. rubric:: Using the hub status light
|
||||
|
||||
@@ -17,20 +16,6 @@ Technic Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.light.animate
|
||||
|
||||
.. rubric:: Using the IMU
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.up
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.tilt
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.acceleration
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.angular_velocity
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.heading
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.reset_heading
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.battery.voltage
|
||||
@@ -63,37 +48,3 @@ Creating light animations
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/light_animate.py
|
||||
|
||||
IMU examples
|
||||
---------------
|
||||
|
||||
Testing which way is up
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_up.py
|
||||
|
||||
|
||||
Reading the tilt value
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_tilt.py
|
||||
|
||||
Using a custom hub orientation
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_tilt_blast.py
|
||||
|
||||
Reading acceleration and angular velocity vectors
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_read_vector.py
|
||||
|
||||
Reading acceleration and angular velocity on one axis
|
||||
*****************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_read_scalar.py
|
||||
|
||||
@@ -70,7 +70,6 @@ findings on our `support page`_ so we can make Pybricks even better.
|
||||
robotics
|
||||
media
|
||||
messaging
|
||||
geometry
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
@@ -12,3 +12,12 @@ Powered Up Device
|
||||
.. automethod:: pybricks.iodevices.PUPDevice.read
|
||||
|
||||
.. automethod:: pybricks.iodevices.PUPDevice.write
|
||||
|
||||
Examples
|
||||
-------------------
|
||||
|
||||
Detecting devices
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/iodevices_pupdevice/port_info.py
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
color
|
||||
direction
|
||||
port
|
||||
side
|
||||
stop
|
||||
|
||||
.. pybricks-classlink:: Button
|
||||
@@ -23,7 +22,5 @@
|
||||
|
||||
.. pybricks-classlink:: Port
|
||||
|
||||
.. pybricks-classlink:: Side
|
||||
|
||||
.. pybricks-classlink:: Stop
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
Side
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. class:: Side
|
||||
|
||||
Side of a hub or a sensor. These devices are
|
||||
mostly rectangular boxes with six sides:
|
||||
|
||||
.. autoattribute:: pybricks.parameters.Side.TOP
|
||||
:annotation:
|
||||
|
||||
.. autoattribute:: pybricks.parameters.Side.BOTTOM
|
||||
:annotation:
|
||||
|
||||
.. autoattribute:: pybricks.parameters.Side.FRONT
|
||||
:annotation:
|
||||
|
||||
.. autoattribute:: pybricks.parameters.Side.BACK
|
||||
:annotation:
|
||||
|
||||
.. autoattribute:: pybricks.parameters.Side.LEFT
|
||||
:annotation:
|
||||
|
||||
.. autoattribute:: pybricks.parameters.Side.RIGHT
|
||||
:annotation:
|
||||
|
||||
|
||||
Screens or light matrices have only four sides. For those,
|
||||
``TOP`` is treated the same as ``FRONT``, and ``BOTTOM`` is treated the
|
||||
same as ``BACK``. The diagrams below define the sides for relevant devices.
|
||||
|
||||
**Prime Hub**
|
||||
|
||||
.. figure:: ../../api/images/orientation_primehub_label.png
|
||||
:height: 17 em
|
||||
|
||||
**Inventor Hub**
|
||||
|
||||
.. figure:: ../../api/images/orientation_inventorhub_label.png
|
||||
:height: 17 em
|
||||
|
||||
**Move Hub**
|
||||
|
||||
.. figure:: ../../api/images/orientation_movehub_label.png
|
||||
:height: 17 em
|
||||
|
||||
**Technic Hub**
|
||||
|
||||
.. figure:: ../../api/images/orientation_technichub_label.png
|
||||
:height: 17 em
|
||||
|
||||
**Tilt Sensor**
|
||||
|
||||
.. figure:: ../../api/images/orientation_tiltsensor_label.png
|
||||
:height: 17 em
|
||||
@@ -26,6 +26,12 @@ Motors without Rotation Sensors
|
||||
Examples
|
||||
-------------------
|
||||
|
||||
Making a train drive forever
|
||||
************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/motor_dc/motor_dc_battery_box.py
|
||||
|
||||
Making the motor move back and forth
|
||||
************************************
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
ultrasonicsensor
|
||||
forcesensor
|
||||
light
|
||||
remote
|
||||
|
||||
.. pybricks-classlink:: DCMotor
|
||||
|
||||
@@ -79,9 +78,3 @@
|
||||
.. figure:: ../../api/images/light.png
|
||||
:width: 90 %
|
||||
:target: light.html
|
||||
|
||||
.. pybricks-classlink:: Remote
|
||||
|
||||
.. figure:: ../../api/images/pupremote.png
|
||||
:width: 50 %
|
||||
:target: remote.html
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
Remote Control
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. warning::
|
||||
|
||||
This remote is not yet supported.
|
||||
Upvote `this issue <https://github.com/pybricks/support/issues/186>`_ if
|
||||
you want to see this happen.
|
||||
|
||||
.. figure:: ../../api/images/pupremote.png
|
||||
:width: 60 %
|
||||
|
||||
.. autoclass:: pybricks.pupdevices.Remote
|
||||
:no-members:
|
||||
|
||||
.. autoattribute:: pybricks.pupdevices::Remote.address
|
||||
:annotation:
|
||||
|
||||
.. automethod:: pybricks.pupdevices::Remote.light.on
|
||||
|
||||
.. automethod:: pybricks.pupdevices::Remote.light.off
|
||||
|
||||
.. automethod:: pybricks.pupdevices::Remote.buttons.pressed
|
||||
@@ -1,3 +1,4 @@
|
||||
// Since Pybricks Code is an "app", all external links get opened in new tab/window
|
||||
// https://stackoverflow.com/a/62742435/1976323
|
||||
$(document).ready(function () {
|
||||
$('a[href^="http://"], a[href^="https://"]').not('a[class*=internal]').attr('target', '_blank');
|
||||
+1
-6
@@ -91,7 +91,7 @@ version = re.match(r'(v\d+\.\d+)', release)[0]
|
||||
language = None
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = 'xcode'
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
@@ -147,11 +147,6 @@ else:
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
# a little extra javascript
|
||||
html_js_files = [
|
||||
'js/custom.js'
|
||||
]
|
||||
|
||||
html_context = {
|
||||
'disclaimer': _DISCLAIMER,
|
||||
}
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
# 1.3.3 - 2021-05-21
|
||||
|
||||
## Changed:
|
||||
- Match example snippet styling to IDE.
|
||||
- Add more examples.
|
||||
|
||||
# 1.3.2 - 2021-04-26
|
||||
|
||||
## Changed:
|
||||
- Theme style fixes.
|
||||
- Example code fixes
|
||||
- Match doc version to firmware version.
|
||||
|
||||
# 1.3.1 - 2021-04-12
|
||||
|
||||
## Changed:
|
||||
- Upgrade sphinx and rtd-theme to fix style issues.
|
||||
|
||||
# 1.3.0 - 2021-04-12
|
||||
|
||||
## Removed:
|
||||
- Removed features which not be in the official 3.0 release. These features
|
||||
are still in beta. They'll come back in future releases once tested.
|
||||
|
||||
# 1.2.0 - 2021-04-09
|
||||
|
||||
## Changed:
|
||||
|
||||
@@ -18,6 +18,7 @@ html_logo = '../common/images/pybricks-logo-rtd.png'
|
||||
html_show_copyright = False
|
||||
html_show_sphinx = False
|
||||
html_css_files = ['css/ide.css']
|
||||
html_js_files = ['js/ide.js']
|
||||
|
||||
imgmath_image_format = 'svg'
|
||||
imgmath_use_preview = True # requires Sphinx v3
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.. include:: ../api/geometry.rst
|
||||
@@ -10,7 +10,6 @@
|
||||
movehub
|
||||
cityhub
|
||||
technichub
|
||||
primehub
|
||||
|
||||
.. pybricks-classlink:: MoveHub
|
||||
|
||||
@@ -30,14 +29,3 @@
|
||||
:height: 10 em
|
||||
:target: technichub.html
|
||||
|
||||
.. pybricks-classlink:: PrimeHub
|
||||
|
||||
.. figure:: ../../api/images/primehub.png
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
.. pybricks-classlink:: InventorHub
|
||||
|
||||
.. figure:: ../../api/images/inventorhub.png
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.. include:: ../../api/hubs/primehub.rst
|
||||
+1
-2
@@ -12,7 +12,6 @@ Pybricks Documentation
|
||||
parameters/index
|
||||
tools/index
|
||||
robotics
|
||||
geometry
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
@@ -30,7 +29,7 @@ commonly used devices and classes are listed below for quick reference.
|
||||
|
||||
.. rubric:: Programmable Hubs
|
||||
|
||||
.. figure:: ../api/images/hubsoverview.png
|
||||
.. figure:: ../api/images/powereduphubs.png
|
||||
:width: 100 %
|
||||
:target: hubs/index.html
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pybricks/ide-docs",
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.3",
|
||||
"description": "Special build of Pybricks API docs for embedding in an IDE.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.. include:: ../../api/parameters/button.rst
|
||||
@@ -1 +1,23 @@
|
||||
.. include:: ../../api/parameters/index.rst
|
||||
:mod:`parameters <pybricks.parameters>` -- Parameters and Constants
|
||||
===================================================================
|
||||
|
||||
.. automodule:: pybricks.parameters
|
||||
:no-members:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:hidden:
|
||||
|
||||
color
|
||||
direction
|
||||
port
|
||||
stop
|
||||
|
||||
.. pybricks-classlink:: Color
|
||||
|
||||
.. pybricks-classlink:: Direction
|
||||
|
||||
.. pybricks-classlink:: Port
|
||||
|
||||
.. pybricks-classlink:: Stop
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.. include:: ../../api/parameters/side.rst
|
||||
@@ -1 +0,0 @@
|
||||
.. include:: ../../api/pupdevices/remote.rst
|
||||
@@ -13,7 +13,7 @@ device = I2CDevice(Port.S2, 0xD2 >> 1)
|
||||
# For this device, we can read the Who Am I
|
||||
# register (0x0F) for the expected value: 211.
|
||||
if 211 not in device.read(0x0F):
|
||||
raise OSError("Device is not attached")
|
||||
raise ValueError("Unexpected I2C device ID")
|
||||
|
||||
# To write data, create a bytes object of one
|
||||
# or more bytes. For example:
|
||||
|
||||
@@ -7,7 +7,7 @@ from math import sin, pi
|
||||
hub = CityHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, None], interval=500)
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
|
||||
wait(10000)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from math import sin, pi
|
||||
hub = PrimeHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, None], interval=500)
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
|
||||
wait(10000)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from math import sin, pi
|
||||
hub = ExampleHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, None], interval=500)
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
|
||||
wait(10000)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from math import sin, pi
|
||||
hub = TechnicHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, None], interval=500)
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
|
||||
wait(10000)
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
from pybricks.iodevices import PUPDevice
|
||||
from pybricks.parameters import Port
|
||||
from uerrno import ENODEV
|
||||
|
||||
# Dictionary of device identifiers along with their name.
|
||||
device_names = {
|
||||
34: "Wedo 2.0 Tilt Sensor",
|
||||
35: "Wedo 2.0 Infrared Sensor",
|
||||
37: "BOOST Color Distance Sensor",
|
||||
38: "BOOST Interactive Motor",
|
||||
46: "Technic Large Motor",
|
||||
47: "Technic Extra Large Motor",
|
||||
48: "SPIKE Medium Angular Motor",
|
||||
49: "SPIKE Large Angular Motor",
|
||||
61: "SPIKE Color Sensor",
|
||||
62: "SPIKE Ultrasonic Sensor",
|
||||
63: "SPIKE Force Sensor",
|
||||
75: "Technic Medium Angular Motor",
|
||||
76: "Technic Large Angular Motor",
|
||||
}
|
||||
|
||||
# Make a list of known ports.
|
||||
ports = [Port.A, Port.B]
|
||||
|
||||
# On hubs that support it, add more ports.
|
||||
try:
|
||||
ports.append(Port.C)
|
||||
ports.append(Port.D)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# On hubs that support it, add more ports.
|
||||
try:
|
||||
ports.append(Port.E)
|
||||
ports.append(Port.F)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# Go through all available ports.
|
||||
for port in ports:
|
||||
|
||||
# Try to get the device, if it is attached.
|
||||
try:
|
||||
device = PUPDevice(port)
|
||||
except OSError as ex:
|
||||
if ex.args[0] == ENODEV:
|
||||
# No device found on this port.
|
||||
print(port, ": ---")
|
||||
continue
|
||||
else:
|
||||
raise
|
||||
|
||||
# Get the device id
|
||||
id = device.info()['id']
|
||||
|
||||
# Look up the name.
|
||||
try:
|
||||
print(port, ":", device_names[id])
|
||||
except KeyError:
|
||||
print(port, ":", "Unknown device with ID", id)
|
||||
@@ -0,0 +1,13 @@
|
||||
from pybricks.pupdevices import DCMotor
|
||||
from pybricks.parameters import Port
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the motor.
|
||||
train_motor = DCMotor(Port.A)
|
||||
|
||||
# Choose the "power" level for your train. Negative means reverse.
|
||||
train_motor.dc(50)
|
||||
|
||||
# Keep doing nothing. The train just keeps going.
|
||||
while True:
|
||||
wait(1000)
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2020 The Pybricks Authors
|
||||
|
||||
from typing import Optional, Tuple, overload
|
||||
from typing import Optional, Tuple, overload, Union
|
||||
from ._common import Control, Motor
|
||||
|
||||
class DriveBase:
|
||||
@@ -11,8 +11,8 @@ class DriveBase:
|
||||
self,
|
||||
left_motor: Motor,
|
||||
right_motor: Motor,
|
||||
wheel_diameter: int,
|
||||
axle_track: int,
|
||||
wheel_diameter: Union[int, float],
|
||||
axle_track: Union[int, float],
|
||||
): ...
|
||||
def drive(self, drive_speed: int, turn_rate: int) -> None: ...
|
||||
def stop(self) -> None: ...
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks"
|
||||
version = "3.0.0a5"
|
||||
version = "3.0.0-rc.1"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
authors = ["The Pybricks Authors <dev@pybricks.com>"]
|
||||
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
|
||||
|
||||
Reference in New Issue
Block a user