Compare commits

..
Author SHA1 Message Date
Laurens Valk 8c6f982aef @pybricks/ide-docs v1.3.2 2021-04-26 20:37:21 +02:00
Martyn Boogaarts a42ebc267b examples/pup/hub_shared: Update light animation examples.
See https://github.com/pybricks/support/issues/253

* Update light_animate.py

corrected syntax

* Update light_animate.py

corrected syntax

* Update light_animate.py

corrected syntax

* Update light_animate.py

corrected syntax
2021-04-26 20:34:54 +02:00
David Lechner e2dea7837b js: only apply target="_blank" to IDE build
On the web, we want to be able to navigate between the various Pybricks
subdomains without opening new tabs. But Pybricks Code is treated as an
"app", we don't want links to open in Pybricks Code.
2021-04-26 20:34:45 +02:00
David Lechner 9bb3e75569 poetry: bump version to match current firmware 2021-04-26 20:34:26 +02:00
Laurens Valk 5437bd92c0 @pybricks/ide-docs v1.3.1 2021-04-12 11:18:28 +02:00
David Lechner 13d9aeea20 poetry: Bump RTD and theme versions.
This is mainly to pull in the requirement of docutils < 0.17 from
sphinx-rtd-theme. Just bumping to latest sphinx doc while we are at it.

Issue: https://github.com/pybricks/pybricks-api/issues/55
2021-04-12 11:17:30 +02:00
Laurens Valk 9594adae48 @pybricks/ide-docs v1.3.0 2021-04-12 11:08:51 +02:00
Laurens Valk 8dd171fc4c v3: Drop parameters Side and Button. 2021-04-12 11:05:26 +02:00
Laurens Valk 5effd921b4 v3: Drop Remote control. 2021-04-12 11:05:22 +02:00
Laurens Valk d503966862 v3: Drop geometry module. 2021-04-12 11:05:17 +02:00
Laurens Valk 7563b1c6cf v3: Drop Prime Hub and Inventor Hub. 2021-04-12 11:05:04 +02:00
Laurens Valk c9132b45db v3: Drop IMU documentation.
This is not officially supported yet, so drop from release docs.
2021-04-12 11:03:28 +02:00
28 changed files with 51 additions and 550 deletions
@@ -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: Build Python package and docs
name: Python package
on: [ push, pull_request ]
-22
View File
@@ -1,22 +0,0 @@
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 }}
-49
View File
@@ -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.
-13
View File
@@ -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
-20
View File
@@ -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
-210
View File
@@ -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
+1 -50
View File
@@ -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
-1
View File
@@ -70,7 +70,6 @@ findings on our `support page`_ so we can make Pybricks even better.
robotics
media
messaging
geometry
.. toctree::
:maxdepth: 1
-9
View File
@@ -12,12 +12,3 @@ Powered Up Device
.. automethod:: pybricks.iodevices.PUPDevice.read
.. automethod:: pybricks.iodevices.PUPDevice.write
Examples
-------------------
Detecting devices
******************************
.. literalinclude::
../../../examples/pup/iodevices_pupdevice/port_info.py
-3
View File
@@ -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
-55
View File
@@ -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
-7
View File
@@ -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
-23
View File
@@ -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 -1
View File
@@ -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 = 'xcode'
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
+18
View File
@@ -1,3 +1,21 @@
# 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:
-1
View File
@@ -1 +0,0 @@
.. include:: ../api/geometry.rst
-12
View File
@@ -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
View File
@@ -1 +0,0 @@
.. include:: ../../api/hubs/primehub.rst
+1 -2
View File
@@ -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 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@pybricks/ide-docs",
"version": "1.2.0",
"version": "1.3.2",
"description": "Special build of Pybricks API docs for embedding in an IDE.",
"repository": {
"type": "git",
-1
View File
@@ -1 +0,0 @@
.. include:: ../../api/parameters/button.rst
+23 -1
View File
@@ -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
View File
@@ -1 +0,0 @@
.. include:: ../../api/parameters/side.rst
-1
View File
@@ -1 +0,0 @@
.. include:: ../../api/pupdevices/remote.rst
+1 -1
View File
@@ -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 ValueError("Unexpected I2C device ID")
raise OSError("Device is not attached")
# To write data, create a bytes object of one
# or more bytes. For example:
@@ -1,60 +0,0 @@
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)
+3 -3
View File
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2020 The Pybricks Authors
from typing import Optional, Tuple, overload, Union
from typing import Optional, Tuple, overload
from ._common import Control, Motor
class DriveBase:
@@ -11,8 +11,8 @@ class DriveBase:
self,
left_motor: Motor,
right_motor: Motor,
wheel_diameter: Union[int, float],
axle_track: Union[int, float],
wheel_diameter: int,
axle_track: int,
): ...
def drive(self, drive_speed: int, turn_rate: int) -> None: ...
def stop(self) -> None: ...
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybricks"
version = "3.0.0-rc.1"
version = "3.0.0b6"
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>" ]