pybricks.common: Charger, IMU and System auto-completion

This commit is contained in:
Pavel Lobodinský
2022-03-02 10:31:53 -06:00
committed by David Lechner
parent 2ba7edab0c
commit d8bd890101
3 changed files with 27 additions and 1 deletions
+3
View File
@@ -4,6 +4,9 @@
## Unreleased
### Added
- Code auto-completion for `hub.charger`, `hub.imu` and `hub.system`.
### Fixed
- Fixed code completion for `DCMotor` and `Motor` classes in MS Python VS Code extension.
- Fixed missing `DCMotor` type in `ev3devices`.
+15
View File
@@ -7,6 +7,12 @@ from .geometry import Axis, Matrix, vector
from .parameters import Button, Color, Direction, Side, Stop, Port
class System:
def set_stop_button(self, button: Button) -> None: ...
def shutdown(self) -> None: ...
def reset_reason(self) -> int: ...
def name(self) -> str: ...
class DCMotor:
def __init__(
self, port: Port, positive_direction: Direction = Direction.CLOCKWISE
@@ -128,6 +134,15 @@ class Battery:
def voltage(self) -> int: ...
def current(self) -> int: ...
class Charger:
def connected(self) -> bool: ...
def status(self) -> int: ...
def current(self) -> int: ...
class SimpleAccelerometer:
def acceleration(self) -> Tuple[int, int, int]: ...
def up(self) -> Side: ...
class Accelerometer:
def neutral(self, top: Axis, front: Axis) -> None: ...
@overload
+9 -1
View File
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2020 The Pybricks Authors
from ._common import Speaker, Battery, ColorLight, LightMatrix, Keypad
from ._common import Battery, ColorLight, Charger, IMU, Keypad, LightMatrix, SimpleAccelerometer, Speaker, System
from .ev3dev._speaker import Speaker as EV3Speaker
from .geometry import Axis
from .media.ev3dev import Image
@@ -17,17 +17,22 @@ class EV3Brick:
class MoveHub:
battery: Battery
light: ColorLight
system: System
imu: SimpleAccelerometer
class CityHub:
battery: Battery
light: ColorLight
system: System
class TechnicHub:
def __init__(self, top_size: Axis, front_side: Axis): ...
battery: Battery
light: ColorLight
system: System
imu: IMU
class PrimeHub:
@@ -37,6 +42,9 @@ class PrimeHub:
display: LightMatrix
buttons: Keypad
speaker: Speaker
system: System
imu: IMU
charger: Charger
class InventorHub(PrimeHub): ...