Compare commits

..
Author SHA1 Message Date
David Lechner 7b4953bc5f pyproject: v3.2.0b5
Update version for `pybricks` Python package release.
2022-11-11 11:24:57 -06:00
David Lechner 62f6fc85a5 jedi: fix code completion for Color and Icon
The pybricks.parameters.Color and Icon types were not working with Jedi
for code completion since the constants were never assigned a value.
2022-11-10 12:23:24 -06:00
Laurens Valk d2b1b2183b pybricks.parameters.Icon: Document it.
Fixes https://github.com/pybricks/pybricks-api/issues/107
2022-11-10 16:38:44 +01:00
David Lechner a236609ebf npm/icons: v1.2.1 2022-11-08 15:06:55 -06:00
Laurens Valk 6c893c136e doc/main/diagrams: Fix City Hub position.
It was accidentally moved to a non-integer position. This causes the PNG to re-render. This increases the file size and makes it looks less crisp.
2022-11-08 19:55:48 +01:00
Laurens Valk f4212f232e doc/main/diagrams: Adjust Move Hub icon scale.
Fixes https://github.com/pybricks/support/issues/773
2022-11-08 19:52:51 +01:00
David Lechner 3a805b0ca9 npm/images: v1.2.0 2022-11-03 13:03:19 -05:00
Laurens Valk c52627cc8f doc/main/diagrams: Add hub icon variants.
This re-exports all hub images in a square format for use as icons while getting correct relative scaling.
2022-11-03 17:07:41 +01:00
David Lechner b84fed1de9 npm/images: add hub-inventor.png file to package 2022-10-28 12:38:07 -05:00
David Lechner d49bc548c7 npm/images: new @pybricks/images package v1.0.0 2022-10-28 12:21:27 -05:00
Barry-Williams 492d6cd2d4 pybricks.robotics.DriveBase: Add basic example. 2022-10-28 08:23:14 +02:00
Laurens Valk be3558167e doc/common/extensions: Fix compatibility labels.
Fixes https://github.com/pybricks/support/issues/754
2022-10-27 15:41:42 +02:00
David Lechner 4573fd2760 LICENSE: update copyright year 2022-10-21 13:14:13 -05:00
David Lechner 2a23c2e81d npm/jedi: v1.1.0
- Update pybricks_jedi Python package dependency.
- Bump JavaScript package version for release.
2022-10-21 13:08:14 -05:00
32 changed files with 1168 additions and 51 deletions
+23
View File
@@ -0,0 +1,23 @@
name: Release @pybricks/images
on:
push:
tags:
- '@pybricks/images/**'
jobs:
publish_ide_docs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: ./build.py
working-directory: npm/images
- run: yarn publish
working-directory: npm/images/build
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
+5
View File
@@ -4,6 +4,11 @@
## Unreleased
## 3.2.0b5 - 2022-11-11
### Fixed
- Fixed Jedi code completion for `Color` and `Icon` classes in `pybricks.parameters`.
## 3.2.0b4 - 2022-10-21
### Added
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018-2021 The Pybricks Authors
Copyright (c) 2018-2022 The Pybricks Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+3 -3
View File
@@ -24,8 +24,8 @@ HUB_FEATURES = {
"movehub": {"movehub"} | FEATURES_SMALL,
"cityhub": {"cityhub"} | FEATURES_MEDIUM,
"technichub": {"technichub"} | FEATURES_MEDIUM,
"primehub": {"primehub", "inventorhub"} | FEATURES_LARGE,
"inventorhub": {"primehub", "inventorhub"} | FEATURES_LARGE,
"primehub": {"primehub", "inventorhub", "light-matrix"} | FEATURES_LARGE,
"inventorhub": {"primehub", "inventorhub", "light-matrix"} | FEATURES_LARGE,
"essentialhub": {"essentialhub"} | FEATURES_LARGE,
}
@@ -58,7 +58,7 @@ class PybricksRequirementsStaticDirective(Directive):
# Cell with image of a hub.
hub_cell = """
<th><div class="align-default">
<img alt="" src="{0}_images/compat_{1}_{2}_label.png">
<img alt="" src="{0}_images/compat_{1}_{2}.png">
</div></th>
"""
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

+86
View File
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="525"
height="525"
viewBox="0 0 525 525"
sodipodi:docname="icon_cityhub.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath860">
<rect
style="fill:#6ab0de;fill-opacity:1;stroke:#6ab0de;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect862"
width="589.10107"
height="96.333336"
x="235.33333"
y="-236.00002" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1040">
<rect
style="fill:#1e1e1e;fill-opacity:1;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1042"
width="128.5101"
height="19.934668"
x="827.15656"
y="74.666672" />
</clipPath>
</defs>
<sodipodi:namedview
pagecolor="#fcfcfc"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1856"
inkscape:window-height="1136"
id="namedview4"
showgrid="false"
inkscape:zoom="0.9950413"
inkscape:cx="301.49502"
inkscape:cy="344.20682"
inkscape:window-x="64"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-global="false"
inkscape:pagecheckerboard="0" />
<image
width="349"
height="400"
preserveAspectRatio="none"
xlink:href="../cad/output/hub-city.png"
id="image834"
x="90"
y="55" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="525"
height="525"
viewBox="0 0 525 525"
sodipodi:docname="icon_essentialhub.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath860">
<rect
style="fill:#6ab0de;fill-opacity:1;stroke:#6ab0de;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect862"
width="589.10107"
height="96.333336"
x="235.33333"
y="-236.00002" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1040">
<rect
style="fill:#1e1e1e;fill-opacity:1;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1042"
width="128.5101"
height="19.934668"
x="827.15656"
y="74.666672" />
</clipPath>
</defs>
<sodipodi:namedview
pagecolor="#fcfcfc"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1856"
inkscape:window-height="1136"
id="namedview4"
showgrid="false"
inkscape:zoom="0.9950413"
inkscape:cx="301.49502"
inkscape:cy="344.20682"
inkscape:window-x="64"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-global="false"
inkscape:pagecheckerboard="0" />
<image
width="379"
height="338"
preserveAspectRatio="none"
xlink:href="../cad/output/hub-essential.png"
id="image1283"
x="80"
y="80" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="525"
height="525"
viewBox="0 0 525 525"
sodipodi:docname="icon_inventorhub.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath860">
<rect
style="fill:#6ab0de;fill-opacity:1;stroke:#6ab0de;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect862"
width="589.10107"
height="96.333336"
x="235.33333"
y="-236.00002" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1040">
<rect
style="fill:#1e1e1e;fill-opacity:1;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1042"
width="128.5101"
height="19.934668"
x="827.15656"
y="74.666672" />
</clipPath>
</defs>
<sodipodi:namedview
pagecolor="#fcfcfc"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1856"
inkscape:window-height="1136"
id="namedview4"
showgrid="false"
inkscape:zoom="0.9950413"
inkscape:cx="301.49502"
inkscape:cy="344.20682"
inkscape:window-x="64"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-global="false"
inkscape:pagecheckerboard="0" />
<image
width="513"
height="465"
preserveAspectRatio="none"
xlink:href="../cad/output/hub-inventor.png"
id="image1430"
x="7"
y="21" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

+87
View File
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="525"
height="525"
viewBox="0 0 525 525"
sodipodi:docname="icon_movehub.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath860">
<rect
style="fill:#6ab0de;fill-opacity:1;stroke:#6ab0de;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect862"
width="589.10107"
height="96.333336"
x="235.33333"
y="-236.00002" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1040">
<rect
style="fill:#1e1e1e;fill-opacity:1;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1042"
width="128.5101"
height="19.934668"
x="827.15656"
y="74.666672" />
</clipPath>
</defs>
<sodipodi:namedview
pagecolor="#fcfcfc"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1856"
inkscape:window-height="1136"
id="namedview4"
showgrid="false"
inkscape:zoom="0.9950413"
inkscape:cx="301.49502"
inkscape:cy="344.20682"
inkscape:window-x="64"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-global="false"
inkscape:pagecheckerboard="0" />
<image
width="525"
height="475.44"
preserveAspectRatio="none"
xlink:href="../cad/output/hub-move.png"
id="image1015"
x="0"
y="18"
style="stroke-width:1.19048" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="525"
height="525"
viewBox="0 0 525 525"
sodipodi:docname="icon_primehub.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath860">
<rect
style="fill:#6ab0de;fill-opacity:1;stroke:#6ab0de;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect862"
width="589.10107"
height="96.333336"
x="235.33333"
y="-236.00002" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1040">
<rect
style="fill:#1e1e1e;fill-opacity:1;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1042"
width="128.5101"
height="19.934668"
x="827.15656"
y="74.666672" />
</clipPath>
</defs>
<sodipodi:namedview
pagecolor="#fcfcfc"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1856"
inkscape:window-height="1136"
id="namedview4"
showgrid="false"
inkscape:zoom="0.9950413"
inkscape:cx="301.49502"
inkscape:cy="344.20682"
inkscape:window-x="64"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-global="false"
inkscape:pagecheckerboard="0" />
<image
width="513"
height="465"
preserveAspectRatio="none"
xlink:href="../cad/output/hub-prime.png"
id="image1329"
x="7"
y="21" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="525"
height="525"
viewBox="0 0 525 525"
sodipodi:docname="icon_technichub.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath860">
<rect
style="fill:#6ab0de;fill-opacity:1;stroke:#6ab0de;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect862"
width="589.10107"
height="96.333336"
x="235.33333"
y="-236.00002" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1040">
<rect
style="fill:#1e1e1e;fill-opacity:1;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1042"
width="128.5101"
height="19.934668"
x="827.15656"
y="74.666672" />
</clipPath>
</defs>
<sodipodi:namedview
pagecolor="#fcfcfc"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1856"
inkscape:window-height="1136"
id="namedview4"
showgrid="false"
inkscape:zoom="0.9950413"
inkscape:cx="301.49502"
inkscape:cy="344.20682"
inkscape:window-x="64"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-global="false"
inkscape:pagecheckerboard="0" />
<image
width="525"
height="447.47662"
preserveAspectRatio="none"
xlink:href="../cad/output/hub-technic.png"
id="image985"
x="0"
y="35.996998"
style="stroke-width:1.01905" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

+3 -1
View File
@@ -177,13 +177,15 @@ Changing the display orientation
.. literalinclude::
../../../examples/pup/hub_primehub/display_orientation_imu.py
.. _make_icons:
Making your own images
**********************
.. literalinclude::
../../../examples/pup/hub_primehub/display_matrix.py
Combining images to make expressions
Combining icons to make expressions
************************************
.. literalinclude::
+8
View File
@@ -0,0 +1,8 @@
.. pybricks-requirements:: light-matrix
Icon
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pybricks.parameters.Icon
See the :ref:`make_icons` section for examples.
+3
View File
@@ -13,6 +13,7 @@
button
color
direction
icon
port
side
stop
@@ -23,6 +24,8 @@
.. pybricks-classlink:: Direction
.. pybricks-classlink:: Icon
.. pybricks-classlink:: Port
.. pybricks-classlink:: Side
+9
View File
@@ -104,3 +104,12 @@
.. autoattribute:: pybricks.robotics.DriveBase.heading_control
:annotation:
Examples
-------------------
Driving straight and turning in place
**********************************************
.. literalinclude::
../../examples/pup/robotics/drivebase_basics.py
+24
View File
@@ -0,0 +1,24 @@
from pybricks.pupdevices import Motor
from pybricks.parameters import Port, Direction
from pybricks.robotics import DriveBase
# Initialize both motors. In this example, the motor on the
# left must turn counterclockwise to make the robot go forward.
left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.B)
# Initialize the drive base. In this example, the wheel diameter is 56mm.
# The distance between the two wheel-ground contact points is 112mm.
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112)
# Drive forward by 500mm (half a meter).
drive_base.straight(500)
# Turn around clockwise (180 degrees)
drive_base.turn(180)
# Drive forward again to drive back.
drive_base.straight(500)
# Turn around counterclockwise.
drive_base.turn(-180)
+3
View File
@@ -4,6 +4,9 @@
## Unreleased
### Fixed
- Fixed code completion for `Color` and `Icon` classes in `pybricks.parameters`.
## 1.2.0 - 2022-10-21
### Added
+139
View File
@@ -0,0 +1,139 @@
import json
import pytest
from pybricks_jedi import CompletionItem, complete
def _create_snippet(class_name: str) -> str:
"""
Creates a code snippet::
from pybricks.parameters import {class_name}
{class_name}.
Args:
line: The value substituted for ``{class_name}``
"""
return "\n".join(
(f"from pybricks.parameters import {class_name}", f"{class_name}.")
)
ENUMS = [
pytest.param(
"Button",
[
"BEACON",
"BLUETOOTH",
"CENTER",
"DOWN",
"LEFT",
"LEFT_DOWN",
"LEFT_MINUS",
"LEFT_PLUS",
"LEFT_UP",
"RIGHT",
"RIGHT_DOWN",
"RIGHT_MINUS",
"RIGHT_PLUS",
"RIGHT_UP",
"UP",
],
),
pytest.param(
"Color",
[
"BLACK",
"BLUE",
"BROWN",
"CYAN",
"GRAY",
"GREEN",
"MAGENTA",
"NONE",
"ORANGE",
"RED",
"VIOLET",
"WHITE",
"YELLOW",
],
),
pytest.param("Direction", ["CLOCKWISE", "COUNTERCLOCKWISE"]),
pytest.param(
"Icon",
[
"ARROW_DOWN",
"ARROW_LEFT",
"ARROW_LEFT_DOWN",
"ARROW_LEFT_UP",
"ARROW_RIGHT",
"ARROW_RIGHT_DOWN",
"ARROW_RIGHT_UP",
"ARROW_UP",
"CIRCLE",
"CLOCKWISE",
"COUNTERCLOCKWISE",
"DOWN",
"EMPTY",
"EYE_LEFT",
"EYE_LEFT_BLINK",
"EYE_LEFT_BROW",
"EYE_LEFT_BROW_UP",
"EYE_RIGHT",
"EYE_RIGHT_BLINK",
"EYE_RIGHT_BROW",
"EYE_RIGHT_BROW_UP",
"FALSE",
"FULL",
"HAPPY",
"HEART",
"LEFT",
"PAUSE",
"RIGHT",
"SAD",
"SQUARE",
"TRIANGLE_DOWN",
"TRIANGLE_LEFT",
"TRIANGLE_RIGHT",
"TRIANGLE_UP",
"TRUE",
"UP",
],
),
pytest.param("Port", ["A", "B", "C", "D", "E", "F", "S1", "S2", "S3", "S4"]),
pytest.param("Side", ["BACK", "BOTTOM", "FRONT", "LEFT", "RIGHT", "TOP"]),
pytest.param("Stop", ["BRAKE", "COAST", "HOLD"]),
]
@pytest.mark.parametrize("class_name,members", ENUMS)
def test_get_parameter_class_member_completion(class_name: str, members: list[str]):
code = _create_snippet(class_name)
completions: list[CompletionItem] = json.loads(
complete(code, 2, len(class_name) + 2)
)
assert [c["insertText"] for c in completions] == members
def test_get_parameter_color_completion():
code = "\n".join(["from pybricks.parameters import Color", "Color.RED."])
completions: list[CompletionItem] = json.loads(complete(code, 2, 11))
assert [c["insertText"] for c in completions] == [
"BLACK",
"BLUE",
"BROWN",
"CYAN",
"GRAY",
"GREEN",
"h",
"MAGENTA",
"NONE",
"ORANGE",
"RED",
"s",
"v",
"VIOLET",
"WHITE",
"YELLOW",
]
+2
View File
@@ -0,0 +1,2 @@
version-tag-prefix "@pybricks/images/v"
version-git-message "@pybricks/images v%s"
+23
View File
@@ -0,0 +1,23 @@
# Changelog
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
## 1.2.1 - 2022-11-08
### Changed
- Changed size of some icons.
## 1.2.0 - 2022-10-28
### Changed
- Changed all icon files to have the same dimensions.
## 1.1.0 - 2022-10-28
### Added
- Added MINDSTORMS Robot Inventor hub image.
## 1.0.0 - 2022-10-28
### Added
- Added new @pybricks/images package.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018-2022 The Pybricks Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+5
View File
@@ -0,0 +1,5 @@
@pybricks/images
================
Image resource for Pybricks Code.
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
import json
import pathlib
import shutil
BUILD_DIR = (pathlib.Path(__file__).parent / "build").resolve()
IMAGE_DIR = (
pathlib.Path(__file__).parent.parent.parent / "doc" / "main" / "diagrams"
).resolve()
HUBS = ["move", "city", "technic", "prime", "essential", "inventor"]
package_json = {
"name": "@pybricks/images",
"version": "1.2.1",
"description": "Distribution of Pybricks images.",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/pybricks/pybricks-api",
"directory": "npm/images",
},
"publishConfig": {"registry": "https://registry.npmjs.org", "access": "public"},
}
# ensure empty build directory so we don't end up with stale files
shutil.rmtree(BUILD_DIR, True)
BUILD_DIR.mkdir()
# copy the hub images
for h in HUBS:
shutil.copyfile(IMAGE_DIR / f"icon_{h}hub.png", BUILD_DIR / f"hub-{h}.png")
# generate package.json file
# create "exports" item for hub images.
package_json["exports"] = {f"./hub-{h}.png": f"./hub-{h}.png" for h in HUBS}
with open(BUILD_DIR / "package.json", "w") as f:
json.dump(package_json, f, indent=2)
# copy additional files
ROOT_DIR = (pathlib.Path(__file__).parent).resolve()
for file in "README.md", "CHANGELOG.md", "LICENSE":
shutil.copy(ROOT_DIR / file, BUILD_DIR / file)
+5
View File
@@ -2,6 +2,11 @@
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
## 1.1.0 - 2022-10-21
### Changed
- Updated `pybricks_jedi` Python package to v1.2.0.
## 1.0.1 - 2022-09-07
### Fixed
+2 -2
View File
@@ -12,7 +12,7 @@ BUILD_DIR = (pathlib.Path(__file__).parent / "build").resolve()
package_json = {
"name": "@pybricks/jedi",
"version": "1.0.1",
"version": "1.2.0",
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
"repository": {
"type": "git",
@@ -38,7 +38,7 @@ subprocess.check_call(
"pip",
"download",
"--only-binary=any",
"pybricks-jedi==1.1.0",
"pybricks-jedi==1.2.0",
],
cwd=BUILD_DIR,
)
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybricks"
version = "3.2.0b4"
version = "3.2.0b5"
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>" ]
+323 -43
View File
@@ -60,21 +60,43 @@ class _PybricksEnum(Enum, metaclass=_PybricksEnumMeta):
class Color:
"""Light or surface color."""
h: int
s: int
v: int
NONE: Color = ...
BLACK: Color = ...
GRAY: Color = ...
WHITE: Color = ...
RED: Color = ...
ORANGE: Color = ...
BROWN: Color = ...
YELLOW: Color = ...
GREEN: Color = ...
CYAN: Color = ...
BLUE: Color = ...
VIOLET: Color = ...
MAGENTA: Color = ...
def __init__(self, h: Number, s: Number = 100, v: Number = 100):
"""Color(h, s=100, v=100)
Arguments:
h (Number, deg): Hue (0--360)
h (Number, deg): Hue.
s (Number, %): Saturation.
v (Number, %): Brightness value.
"""
self.h = h % 360
self.s = max(0, min(s, 100))
self.v = max(0, min(v, 100))
self.h = int(h) % 360
"""
The hue.
"""
self.s = max(0, min(int(s), 100))
"""
The saturation.
"""
self.v = max(0, min(int(v), 100))
"""
The brightness value.
"""
def __repr__(self):
return "Color(h={}, s={}, v={})".format(self.h, self.s, self.v)
@@ -185,39 +207,297 @@ class Side(_PybricksEnum):
class Icon:
UP: _Matrix
DOWN: _Matrix
LEFT: _Matrix
RIGHT: _Matrix
ARROW_RIGHT_UP: _Matrix
ARROW_RIGHT_DOWN: _Matrix
ARROW_LEFT_UP: _Matrix
ARROW_LEFT_DOWN: _Matrix
ARROW_UP: _Matrix
ARROW_DOWN: _Matrix
ARROW_LEFT: _Matrix
ARROW_RIGHT: _Matrix
HAPPY: _Matrix
SAD: _Matrix
EYE_LEFT: _Matrix
EYE_RIGHT: _Matrix
EYE_LEFT_BLINK: _Matrix
EYE_RIGHT_BLINK: _Matrix
EYE_RIGHT_BROW: _Matrix
EYE_LEFT_BROW: _Matrix
EYE_LEFT_BROW_UP: _Matrix
EYE_RIGHT_BROW_UP: _Matrix
HEART: _Matrix
PAUSE: _Matrix
EMPTY: _Matrix
FULL: _Matrix
SQUARE: _Matrix
TRIANGLE_RIGHT: _Matrix
TRIANGLE_LEFT: _Matrix
TRIANGLE_UP: _Matrix
TRIANGLE_DOWN: _Matrix
CIRCLE: _Matrix
CLOCKWISE: _Matrix
COUNTERCLOCKWISE: _Matrix
TRUE: _Matrix
FALSE: _Matrix
"""Icons to display on a light matrix.
Each of the following attributes are matrices. This means you can scale
icons to adjust the brightness or add icons to make composites.
"""
UP: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
"""
DOWN: _Matrix = ...
"""
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
LEFT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨🟨
| ⬜⬜🟨⬜⬜
"""
RIGHT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| 🟨🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_RIGHT_UP: _Matrix = ...
"""
| ⬜⬜🟨🟨🟨
| ⬜⬜⬜🟨🟨
| ⬜⬜🟨⬜🟨
| ⬜🟨⬜⬜⬜
| 🟨⬜⬜⬜⬜
"""
ARROW_RIGHT_DOWN: _Matrix = ...
"""
| 🟨⬜⬜⬜⬜
| ⬜🟨⬜⬜⬜
| ⬜⬜🟨⬜🟨
| ⬜⬜⬜🟨🟨
| ⬜⬜🟨🟨🟨
"""
ARROW_LEFT_UP: _Matrix = ...
"""
| 🟨🟨🟨⬜⬜
| 🟨🟨⬜⬜⬜
| 🟨⬜🟨⬜⬜
| ⬜⬜⬜🟨⬜
| ⬜⬜⬜⬜🟨
"""
ARROW_LEFT_DOWN: _Matrix = ...
"""
| ⬜⬜⬜⬜🟨
| ⬜⬜⬜🟨⬜
| 🟨⬜🟨⬜⬜
| 🟨🟨⬜⬜⬜
| 🟨🟨🟨⬜⬜
"""
ARROW_UP: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨⬜🟨⬜🟨
| ⬜⬜🟨⬜⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_DOWN: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜⬜🟨⬜⬜
| 🟨⬜🟨⬜🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_LEFT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜🟨⬜⬜⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨⬜⬜⬜
| ⬜⬜🟨⬜⬜
"""
ARROW_RIGHT: _Matrix = ...
"""
| ⬜⬜🟨⬜⬜
| ⬜⬜⬜🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜⬜⬜🟨⬜
| ⬜⬜🟨⬜⬜
"""
HAPPY: _Matrix = ...
"""
| 🟨🟨⬜🟨🟨
| 🟨🟨⬜🟨🟨
| ⬜⬜⬜⬜⬜
| 🟨⬜⬜⬜🟨
| ⬜🟨🟨🟨⬜
"""
SAD: _Matrix = ...
"""
| 🟨🟨⬜🟨🟨
| 🟨🟨⬜🟨🟨
| ⬜⬜⬜⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨⬜⬜⬜🟨
"""
EYE_LEFT: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| 🟨🟨⬜⬜⬜
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
"""
EYE_LEFT_BLINK: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT_BLINK: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT_BROW: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_LEFT_BROW: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_LEFT_BROW_UP: _Matrix = ...
"""
| 🟨🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
EYE_RIGHT_BROW_UP: _Matrix = ...
"""
| ⬜⬜⬜🟨🟨
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
HEART: _Matrix = ...
"""
| ⬜🟨⬜🟨⬜
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
"""
PAUSE: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜🟨⬜🟨⬜
| ⬜🟨⬜🟨⬜
| ⬜🟨⬜🟨⬜
| ⬜⬜⬜⬜⬜
"""
EMPTY: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
FULL: _Matrix = ...
"""
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
"""
SQUARE: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨🟨⬜
| ⬜⬜⬜⬜⬜
"""
TRIANGLE_RIGHT: _Matrix = ...
"""
| ⬜🟨⬜⬜⬜
| ⬜🟨🟨⬜⬜
| ⬜🟨🟨🟨⬜
| ⬜🟨🟨⬜⬜
| ⬜🟨⬜⬜⬜
"""
TRIANGLE_LEFT: _Matrix = ...
"""
| ⬜⬜⬜🟨⬜
| ⬜⬜🟨🟨⬜
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨🟨⬜
| ⬜⬜⬜🟨⬜
"""
TRIANGLE_UP: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| ⬜⬜🟨⬜⬜
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| ⬜⬜⬜⬜⬜
"""
TRIANGLE_DOWN: _Matrix = ...
"""
| ⬜⬜⬜⬜⬜
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
| ⬜⬜🟨⬜⬜
| ⬜⬜⬜⬜⬜
"""
CIRCLE: _Matrix = ...
"""
| ⬜🟨🟨🟨⬜
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| 🟨🟨🟨🟨🟨
| ⬜🟨🟨🟨⬜
"""
CLOCKWISE: _Matrix = ...
"""
| 🟨🟨🟨🟨⬜
| 🟨⬜⬜🟨⬜
| 🟨⬜⬜🟨⬜
| 🟨⬜🟨🟨🟨
| ⬜⬜⬜🟨⬜
"""
COUNTERCLOCKWISE: _Matrix = ...
"""
| ⬜🟨🟨🟨🟨
| ⬜🟨⬜⬜🟨
| ⬜🟨⬜⬜🟨
| 🟨🟨🟨⬜🟨
| ⬜🟨⬜⬜⬜
"""
TRUE: _Matrix = ...
"""
| ⬜⬜⬜⬜🟨
| ⬜⬜⬜🟨⬜
| 🟨⬜🟨⬜⬜
| ⬜🟨⬜⬜⬜
| ⬜⬜⬜⬜⬜
"""
FALSE: _Matrix = ...
"""
| 🟨⬜⬜⬜🟨
| ⬜🟨⬜🟨⬜
| ⬜⬜🟨⬜⬜
| ⬜🟨⬜🟨⬜
| 🟨⬜⬜⬜🟨
"""