mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 17:14:41 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ea780cc9e | ||
|
|
78a8fea78f | ||
|
|
99a7c69ac5 | ||
|
|
1a64ba718f | ||
|
|
6d332deb3f | ||
|
|
a7df6988ab | ||
|
|
a2e17f6889 | ||
|
|
866b50fef6 | ||
|
|
9c7378ce64 | ||
|
|
3b20a811cb | ||
|
|
73cc441edb | ||
|
|
7770a88aa0 | ||
|
|
f06caa32bc | ||
|
|
fb8198fe8f | ||
|
|
3dad15ac11 | ||
|
|
790fcfa66a | ||
|
|
d108d7c163 | ||
|
|
7ce3721b48 | ||
|
|
d0bfbcb4d1 | ||
|
|
2aadc75f2c | ||
|
|
8bf42c7d2d |
@@ -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 }}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
************************************
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
# 1.3.3 - 2021-05-21
|
||||
|
||||
## Changed:
|
||||
- Match example snippet styling to IDE.
|
||||
- Add more examples.
|
||||
|
||||
# 1.3.2 - 2021-04-26
|
||||
|
||||
## Changed:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pybricks/ide-docs",
|
||||
"version": "1.3.2",
|
||||
"version": "1.3.3",
|
||||
"description": "Special build of Pybricks API docs for embedding in an IDE.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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.0b6"
|
||||
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