all: Format with black.

Also activate auto formatting. Bump flake8 and mark black
disagreements in setup.cfg.
This commit is contained in:
Laurens Valk
2022-05-27 16:22:05 +02:00
parent 24f7d7c288
commit bd7806d2d4
60 changed files with 716 additions and 709 deletions
+1 -4
View File
@@ -71,9 +71,7 @@ class DCMotor:
"""Generic class to control simple motors without rotation sensors, such
as train motors."""
def __init__(
self, port: Port, positive_direction: Direction = Direction.CLOCKWISE
):
def __init__(self, port: Port, positive_direction: Direction = Direction.CLOCKWISE):
"""DCMotor(port, positive_direction=Direction.CLOCKWISE)
Arguments:
@@ -905,7 +903,6 @@ class Accelerometer(SimpleAccelerometer):
class IMU(Accelerometer):
def heading(self):
"""Gets the heading angle relative to the starting orientation. It is a
a positive rotation around the :ref:`z-axis in the robot
+1 -3
View File
@@ -6,7 +6,6 @@ from typing import Collection, Iterable, Optional, Tuple, Union, overload
from .geometry import Axis, Matrix, vector
from .parameters import Button, Color, Direction, Side, Stop, Port
class Control:
@overload
def limits(self) -> Tuple[int, int, int]: ...
@@ -45,7 +44,6 @@ class Control:
def stalled(self) -> bool: ...
def done(self) -> bool: ...
class Speaker:
@overload
def volume(self) -> int: ...
@@ -70,7 +68,7 @@ class ColorLight:
class LightArray:
def __init__(self, n: int): ...
def on(self, brightness: Union[int,(int, int, int, int)]) -> None: ...
def on(self, brightness: Union[int, (int, int, int, int)]) -> None: ...
def off(self) -> None: ...
def blink(self, durations: Collection[int]) -> None: ...
def animate(self, brightness_values: Collection[int], interval: int) -> None: ...
+1 -1
View File
@@ -97,7 +97,7 @@ class Speaker:
"""
pass
def set_volume(self, volume, which='_all_'):
def set_volume(self, volume, which="_all_"):
"""Sets the speaker volume.
Arguments:
+5 -6
View File
@@ -5,17 +5,16 @@ from typing import Iterable, Optional, Union
from pybricks.media.ev3dev import SoundFile
class Speaker:
def beep(self, frequency: int = 500, duration: int = 100) -> None: ...
def play_notes(self, notes: Iterable[str], tempo: int = 120) -> None: ...
def play_file(self, file_name: Union[SoundFile, str]) -> None: ...
def say(self, text: str) -> None: ...
def set_speech_options(
self,
language: Optional[str] = None,
voice: Optional[str] = None,
speed: Optional[int] = None,
pitch: Optional[int] = None,
self,
language: Optional[str] = None,
voice: Optional[str] = None,
speed: Optional[int] = None,
pitch: Optional[int] = None,
): ...
def set_volume(self, volume: int, which: str = "_all_") -> None: ...
+1
View File
@@ -55,6 +55,7 @@ class Axis:
.. data:: Z = vector(0, 0, 1)
"""
X = vector(1, 0, 0)
Y = vector(0, 1, 0)
Z = vector(0, 0, 1)
-1
View File
@@ -9,7 +9,6 @@ class Matrix:
def T(self) -> Matrix: ...
@property
def shape(self) -> Tuple[int, int]: ...
def __add__(self, other) -> Matrix: ...
def __iadd__(self, other) -> Matrix: ...
def __sub__(self, other) -> Matrix: ...
+30 -19
View File
@@ -2,11 +2,17 @@
# Copyright (c) 2018-2020 The Pybricks Authors
"""LEGO® Programmable Hubs."""
from ._common import (Speaker as _Speaker, Battery as _Battery,
ColorLight as _ColorLight, Keypad as _Keypad,
LightMatrix as _LightMatrix, IMU as _IMU,
Charger as _Charger, System as _System,
SimpleAccelerometer as _SimpleAccelerometer)
from ._common import (
Speaker as _Speaker,
Battery as _Battery,
ColorLight as _ColorLight,
Keypad as _Keypad,
LightMatrix as _LightMatrix,
IMU as _IMU,
Charger as _Charger,
System as _System,
SimpleAccelerometer as _SimpleAccelerometer,
)
from .ev3dev._speaker import Speaker as _EV3Speaker
from .geometry import Axis as _Axis
from .media.ev3dev import Image as _Image
@@ -18,14 +24,16 @@ class EV3Brick:
# These class attributes are here for auto-documentation only.
# In reality, they are instance attributes created by __init__.
buttons = _Keypad((
_Button.LEFT,
_Button.RIGHT,
_Button.CENTER,
_Button.UP,
_Button.DOWN,
))
screen = _Image('_screen_')
buttons = _Keypad(
(
_Button.LEFT,
_Button.RIGHT,
_Button.CENTER,
_Button.UP,
_Button.DOWN,
)
)
screen = _Image("_screen_")
speaker = _EV3Speaker()
battery = _Battery()
light = _ColorLight()
@@ -88,12 +96,14 @@ class PrimeHub:
# These class attributes are here for auto-documentation only.
# In reality, they are instance attributes created by __init__.
battery = _Battery()
buttons = _Keypad((
_Button.LEFT,
_Button.RIGHT,
_Button.CENTER,
_Button.BLUETOOTH,
))
buttons = _Keypad(
(
_Button.LEFT,
_Button.RIGHT,
_Button.CENTER,
_Button.BLUETOOTH,
)
)
charger = _Charger()
light = _ColorLight()
display = _LightMatrix(5, 5)
@@ -120,4 +130,5 @@ class PrimeHub:
class InventorHub(PrimeHub):
"""LEGO® MINDSTORMS Inventor Hub."""
pass
+11 -6
View File
@@ -1,12 +1,21 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2020 The Pybricks Authors
from ._common import Battery, ColorLight, Charger, IMU, Keypad, LightMatrix, SimpleAccelerometer, Speaker, System
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
class EV3Brick:
screen: Image
speaker: EV3Speaker
@@ -20,13 +29,11 @@ class MoveHub:
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
@@ -34,7 +41,6 @@ class TechnicHub:
system: System
imu: IMU
class PrimeHub:
def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X): ...
battery: Battery
@@ -46,5 +52,4 @@ class PrimeHub:
imu: IMU
charger: Charger
class InventorHub(PrimeHub): ...
+152 -151
View File
@@ -155,7 +155,7 @@ class Image:
"""
pass
def print(self, *args, sep=' ', end='\n'):
def print(self, *args, sep=" ", end="\n"):
"""Prints a line of text on |this image|.
This method works like the builtin ``print()`` function, but it writes
@@ -239,8 +239,9 @@ class Font:
DEFAULT = None # assigned later since we can't use Font() here
"""The default font."""
def __init__(self, family=None, size=12, bold=False, monospace=False,
lang=None, script=None):
def __init__(
self, family=None, size=12, bold=False, monospace=False, lang=None, script=None
):
"""The font object will be a font that is the "best" match based on the
parameters given and available fonts installed.
@@ -265,7 +266,7 @@ class Font:
@property
def family(self):
"""Gets the family name of the font."""
return 'Lucida'
return "Lucida"
@property
def style(self):
@@ -273,7 +274,7 @@ class Font:
Can be "Regular" or "Bold".
"""
return 'Regular'
return "Regular"
@property
def width(self):
@@ -312,159 +313,159 @@ class Font:
return 0
Font.DEFAULT = Font('Lucida', 12)
Font.DEFAULT = Font("Lucida", 12)
class SoundFile:
"""Paths to standard EV3 sounds."""
_BASE_PATH = '/usr/share/sounds/ev3dev/'
SHOUTING = _BASE_PATH + 'expressions/shouting.wav'
CHEERING = _BASE_PATH + 'expressions/cheering.wav'
CRYING = _BASE_PATH + 'expressions/crying.wav'
OUCH = _BASE_PATH + 'expressions/ouch.wav'
LAUGHING_2 = _BASE_PATH + 'expressions/laughing_2.wav'
SNEEZING = _BASE_PATH + 'expressions/sneezing.wav'
SMACK = _BASE_PATH + 'expressions/smack.wav'
BOING = _BASE_PATH + 'expressions/boing.wav'
BOO = _BASE_PATH + 'expressions/boo.wav'
UH_OH = _BASE_PATH + 'expressions/uh-oh.wav'
SNORING = _BASE_PATH + 'expressions/snoring.wav'
KUNG_FU = _BASE_PATH + 'expressions/kung_fu.wav'
FANFARE = _BASE_PATH + 'expressions/fanfare.wav'
CRUNCHING = _BASE_PATH + 'expressions/crunching.wav'
MAGIC_WAND = _BASE_PATH + 'expressions/magic_wand.wav'
LAUGHING_1 = _BASE_PATH + 'expressions/laughing_1.wav'
LEFT = _BASE_PATH + 'information/left.wav'
BACKWARDS = _BASE_PATH + 'information/backwards.wav'
RIGHT = _BASE_PATH + 'information/right.wav'
OBJECT = _BASE_PATH + 'information/object.wav'
COLOR = _BASE_PATH + 'information/color.wav'
FLASHING = _BASE_PATH + 'information/flashing.wav'
ERROR = _BASE_PATH + 'information/error.wav'
ERROR_ALARM = _BASE_PATH + 'information/error_alarm.wav'
DOWN = _BASE_PATH + 'information/down.wav'
FORWARD = _BASE_PATH + 'information/forward.wav'
ACTIVATE = _BASE_PATH + 'information/activate.wav'
SEARCHING = _BASE_PATH + 'information/searching.wav'
TOUCH = _BASE_PATH + 'information/touch.wav'
UP = _BASE_PATH + 'information/up.wav'
ANALYZE = _BASE_PATH + 'information/analyze.wav'
STOP = _BASE_PATH + 'information/stop.wav'
DETECTED = _BASE_PATH + 'information/detected.wav'
TURN = _BASE_PATH + 'information/turn.wav'
START = _BASE_PATH + 'information/start.wav'
MORNING = _BASE_PATH + 'communication/morning.wav'
EV3 = _BASE_PATH + 'communication/ev3.wav'
GO = _BASE_PATH + 'communication/go.wav'
GOOD_JOB = _BASE_PATH + 'communication/good_job.wav'
OKEY_DOKEY = _BASE_PATH + 'communication/okey-dokey.wav'
GOOD = _BASE_PATH + 'communication/good.wav'
NO = _BASE_PATH + 'communication/no.wav'
THANK_YOU = _BASE_PATH + 'communication/thank_you.wav'
YES = _BASE_PATH + 'communication/yes.wav'
GAME_OVER = _BASE_PATH + 'communication/game_over.wav'
OKAY = _BASE_PATH + 'communication/okay.wav'
SORRY = _BASE_PATH + 'communication/sorry.wav'
BRAVO = _BASE_PATH + 'communication/bravo.wav'
GOODBYE = _BASE_PATH + 'communication/goodbye.wav'
HI = _BASE_PATH + 'communication/hi.wav'
HELLO = _BASE_PATH + 'communication/hello.wav'
MINDSTORMS = _BASE_PATH + 'communication/mindstorms.wav'
LEGO = _BASE_PATH + 'communication/lego.wav'
FANTASTIC = _BASE_PATH + 'communication/fantastic.wav'
SPEED_IDLE = _BASE_PATH + 'movements/speed_idle.wav'
SPEED_DOWN = _BASE_PATH + 'movements/speed_down.wav'
SPEED_UP = _BASE_PATH + 'movements/speed_up.wav'
BROWN = _BASE_PATH + 'colors/brown.wav'
GREEN = _BASE_PATH + 'colors/green.wav'
BLACK = _BASE_PATH + 'colors/black.wav'
WHITE = _BASE_PATH + 'colors/white.wav'
RED = _BASE_PATH + 'colors/red.wav'
BLUE = _BASE_PATH + 'colors/blue.wav'
YELLOW = _BASE_PATH + 'colors/yellow.wav'
TICK_TACK = _BASE_PATH + 'mechanical/tick_tack.wav'
HORN_1 = _BASE_PATH + 'mechanical/horn_1.wav'
BACKING_ALERT = _BASE_PATH + 'mechanical/backing_alert.wav'
MOTOR_IDLE = _BASE_PATH + 'mechanical/motor_idle.wav'
AIR_RELEASE = _BASE_PATH + 'mechanical/air_release.wav'
AIRBRAKE = _BASE_PATH + 'mechanical/airbrake.wav'
RATCHET = _BASE_PATH + 'mechanical/ratchet.wav'
MOTOR_STOP = _BASE_PATH + 'mechanical/motor_stop.wav'
HORN_2 = _BASE_PATH + 'mechanical/horn_2.wav'
LASER = _BASE_PATH + 'mechanical/laser.wav'
SONAR = _BASE_PATH + 'mechanical/sonar.wav'
MOTOR_START = _BASE_PATH + 'mechanical/motor_start.wav'
INSECT_BUZZ_2 = _BASE_PATH + 'animals/insect_buzz_2.wav'
ELEPHANT_CALL = _BASE_PATH + 'animals/elephant_call.wav'
SNAKE_HISS = _BASE_PATH + 'animals/snake_hiss.wav'
DOG_BARK_2 = _BASE_PATH + 'animals/dog_bark_2.wav'
DOG_WHINE = _BASE_PATH + 'animals/dog_whine.wav'
INSECT_BUZZ_1 = _BASE_PATH + 'animals/insect_buzz_1.wav'
DOG_SNIFF = _BASE_PATH + 'animals/dog_sniff.wav'
T_REX_ROAR = _BASE_PATH + 'animals/t-rex_roar.wav'
INSECT_CHIRP = _BASE_PATH + 'animals/insect_chirp.wav'
DOG_GROWL = _BASE_PATH + 'animals/dog_growl.wav'
SNAKE_RATTLE = _BASE_PATH + 'animals/snake_rattle.wav'
DOG_BARK_1 = _BASE_PATH + 'animals/dog_bark_1.wav'
CAT_PURR = _BASE_PATH + 'animals/cat_purr.wav'
EIGHT = _BASE_PATH + 'numbers/eight.wav'
SEVEN = _BASE_PATH + 'numbers/seven.wav'
SIX = _BASE_PATH + 'numbers/six.wav'
FOUR = _BASE_PATH + 'numbers/four.wav'
TEN = _BASE_PATH + 'numbers/ten.wav'
ONE = _BASE_PATH + 'numbers/one.wav'
TWO = _BASE_PATH + 'numbers/two.wav'
THREE = _BASE_PATH + 'numbers/three.wav'
ZERO = _BASE_PATH + 'numbers/zero.wav'
FIVE = _BASE_PATH + 'numbers/five.wav'
NINE = _BASE_PATH + 'numbers/nine.wav'
READY = _BASE_PATH + 'system/ready.wav'
CONFIRM = _BASE_PATH + 'system/confirm.wav'
GENERAL_ALERT = _BASE_PATH + 'system/general_alert.wav'
CLICK = _BASE_PATH + 'system/click.wav'
OVERPOWER = _BASE_PATH + 'system/overpower.wav'
_BASE_PATH = "/usr/share/sounds/ev3dev/"
SHOUTING = _BASE_PATH + "expressions/shouting.wav"
CHEERING = _BASE_PATH + "expressions/cheering.wav"
CRYING = _BASE_PATH + "expressions/crying.wav"
OUCH = _BASE_PATH + "expressions/ouch.wav"
LAUGHING_2 = _BASE_PATH + "expressions/laughing_2.wav"
SNEEZING = _BASE_PATH + "expressions/sneezing.wav"
SMACK = _BASE_PATH + "expressions/smack.wav"
BOING = _BASE_PATH + "expressions/boing.wav"
BOO = _BASE_PATH + "expressions/boo.wav"
UH_OH = _BASE_PATH + "expressions/uh-oh.wav"
SNORING = _BASE_PATH + "expressions/snoring.wav"
KUNG_FU = _BASE_PATH + "expressions/kung_fu.wav"
FANFARE = _BASE_PATH + "expressions/fanfare.wav"
CRUNCHING = _BASE_PATH + "expressions/crunching.wav"
MAGIC_WAND = _BASE_PATH + "expressions/magic_wand.wav"
LAUGHING_1 = _BASE_PATH + "expressions/laughing_1.wav"
LEFT = _BASE_PATH + "information/left.wav"
BACKWARDS = _BASE_PATH + "information/backwards.wav"
RIGHT = _BASE_PATH + "information/right.wav"
OBJECT = _BASE_PATH + "information/object.wav"
COLOR = _BASE_PATH + "information/color.wav"
FLASHING = _BASE_PATH + "information/flashing.wav"
ERROR = _BASE_PATH + "information/error.wav"
ERROR_ALARM = _BASE_PATH + "information/error_alarm.wav"
DOWN = _BASE_PATH + "information/down.wav"
FORWARD = _BASE_PATH + "information/forward.wav"
ACTIVATE = _BASE_PATH + "information/activate.wav"
SEARCHING = _BASE_PATH + "information/searching.wav"
TOUCH = _BASE_PATH + "information/touch.wav"
UP = _BASE_PATH + "information/up.wav"
ANALYZE = _BASE_PATH + "information/analyze.wav"
STOP = _BASE_PATH + "information/stop.wav"
DETECTED = _BASE_PATH + "information/detected.wav"
TURN = _BASE_PATH + "information/turn.wav"
START = _BASE_PATH + "information/start.wav"
MORNING = _BASE_PATH + "communication/morning.wav"
EV3 = _BASE_PATH + "communication/ev3.wav"
GO = _BASE_PATH + "communication/go.wav"
GOOD_JOB = _BASE_PATH + "communication/good_job.wav"
OKEY_DOKEY = _BASE_PATH + "communication/okey-dokey.wav"
GOOD = _BASE_PATH + "communication/good.wav"
NO = _BASE_PATH + "communication/no.wav"
THANK_YOU = _BASE_PATH + "communication/thank_you.wav"
YES = _BASE_PATH + "communication/yes.wav"
GAME_OVER = _BASE_PATH + "communication/game_over.wav"
OKAY = _BASE_PATH + "communication/okay.wav"
SORRY = _BASE_PATH + "communication/sorry.wav"
BRAVO = _BASE_PATH + "communication/bravo.wav"
GOODBYE = _BASE_PATH + "communication/goodbye.wav"
HI = _BASE_PATH + "communication/hi.wav"
HELLO = _BASE_PATH + "communication/hello.wav"
MINDSTORMS = _BASE_PATH + "communication/mindstorms.wav"
LEGO = _BASE_PATH + "communication/lego.wav"
FANTASTIC = _BASE_PATH + "communication/fantastic.wav"
SPEED_IDLE = _BASE_PATH + "movements/speed_idle.wav"
SPEED_DOWN = _BASE_PATH + "movements/speed_down.wav"
SPEED_UP = _BASE_PATH + "movements/speed_up.wav"
BROWN = _BASE_PATH + "colors/brown.wav"
GREEN = _BASE_PATH + "colors/green.wav"
BLACK = _BASE_PATH + "colors/black.wav"
WHITE = _BASE_PATH + "colors/white.wav"
RED = _BASE_PATH + "colors/red.wav"
BLUE = _BASE_PATH + "colors/blue.wav"
YELLOW = _BASE_PATH + "colors/yellow.wav"
TICK_TACK = _BASE_PATH + "mechanical/tick_tack.wav"
HORN_1 = _BASE_PATH + "mechanical/horn_1.wav"
BACKING_ALERT = _BASE_PATH + "mechanical/backing_alert.wav"
MOTOR_IDLE = _BASE_PATH + "mechanical/motor_idle.wav"
AIR_RELEASE = _BASE_PATH + "mechanical/air_release.wav"
AIRBRAKE = _BASE_PATH + "mechanical/airbrake.wav"
RATCHET = _BASE_PATH + "mechanical/ratchet.wav"
MOTOR_STOP = _BASE_PATH + "mechanical/motor_stop.wav"
HORN_2 = _BASE_PATH + "mechanical/horn_2.wav"
LASER = _BASE_PATH + "mechanical/laser.wav"
SONAR = _BASE_PATH + "mechanical/sonar.wav"
MOTOR_START = _BASE_PATH + "mechanical/motor_start.wav"
INSECT_BUZZ_2 = _BASE_PATH + "animals/insect_buzz_2.wav"
ELEPHANT_CALL = _BASE_PATH + "animals/elephant_call.wav"
SNAKE_HISS = _BASE_PATH + "animals/snake_hiss.wav"
DOG_BARK_2 = _BASE_PATH + "animals/dog_bark_2.wav"
DOG_WHINE = _BASE_PATH + "animals/dog_whine.wav"
INSECT_BUZZ_1 = _BASE_PATH + "animals/insect_buzz_1.wav"
DOG_SNIFF = _BASE_PATH + "animals/dog_sniff.wav"
T_REX_ROAR = _BASE_PATH + "animals/t-rex_roar.wav"
INSECT_CHIRP = _BASE_PATH + "animals/insect_chirp.wav"
DOG_GROWL = _BASE_PATH + "animals/dog_growl.wav"
SNAKE_RATTLE = _BASE_PATH + "animals/snake_rattle.wav"
DOG_BARK_1 = _BASE_PATH + "animals/dog_bark_1.wav"
CAT_PURR = _BASE_PATH + "animals/cat_purr.wav"
EIGHT = _BASE_PATH + "numbers/eight.wav"
SEVEN = _BASE_PATH + "numbers/seven.wav"
SIX = _BASE_PATH + "numbers/six.wav"
FOUR = _BASE_PATH + "numbers/four.wav"
TEN = _BASE_PATH + "numbers/ten.wav"
ONE = _BASE_PATH + "numbers/one.wav"
TWO = _BASE_PATH + "numbers/two.wav"
THREE = _BASE_PATH + "numbers/three.wav"
ZERO = _BASE_PATH + "numbers/zero.wav"
FIVE = _BASE_PATH + "numbers/five.wav"
NINE = _BASE_PATH + "numbers/nine.wav"
READY = _BASE_PATH + "system/ready.wav"
CONFIRM = _BASE_PATH + "system/confirm.wav"
GENERAL_ALERT = _BASE_PATH + "system/general_alert.wav"
CLICK = _BASE_PATH + "system/click.wav"
OVERPOWER = _BASE_PATH + "system/overpower.wav"
class ImageFile:
"""Paths to standard EV3 images."""
_BASE_PATH = '/usr/share/images/ev3dev/mono/'
RIGHT = _BASE_PATH + 'information/right.png'
FORWARD = _BASE_PATH + 'information/forward.png'
ACCEPT = _BASE_PATH + 'information/accept.png'
QUESTION_MARK = _BASE_PATH + 'information/question_mark.png'
STOP_1 = _BASE_PATH + 'information/stop_1.png'
LEFT = _BASE_PATH + 'information/left.png'
DECLINE = _BASE_PATH + 'information/decline.png'
THUMBS_DOWN = _BASE_PATH + 'information/thumbs_down.png'
BACKWARD = _BASE_PATH + 'information/backward.png'
NO_GO = _BASE_PATH + 'information/no_go.png'
WARNING = _BASE_PATH + 'information/warning.png'
STOP_2 = _BASE_PATH + 'information/stop_2.png'
THUMBS_UP = _BASE_PATH + 'information/thumbs_up.png'
EV3 = _BASE_PATH + 'lego/ev3.png'
EV3_ICON = _BASE_PATH + 'lego/ev3_icon.png'
TARGET = _BASE_PATH + 'objects/target.png'
BOTTOM_RIGHT = _BASE_PATH + 'eyes/bottom_right.png'
BOTTOM_LEFT = _BASE_PATH + 'eyes/bottom_left.png'
EVIL = _BASE_PATH + 'eyes/evil.png'
CRAZY_2 = _BASE_PATH + 'eyes/crazy_2.png'
KNOCKED_OUT = _BASE_PATH + 'eyes/knocked_out.png'
PINCHED_RIGHT = _BASE_PATH + 'eyes/pinched_right.png'
WINKING = _BASE_PATH + 'eyes/winking.png'
DIZZY = _BASE_PATH + 'eyes/dizzy.png'
DOWN = _BASE_PATH + 'eyes/down.png'
TIRED_MIDDLE = _BASE_PATH + 'eyes/tired_middle.png'
MIDDLE_RIGHT = _BASE_PATH + 'eyes/middle_right.png'
SLEEPING = _BASE_PATH + 'eyes/sleeping.png'
MIDDLE_LEFT = _BASE_PATH + 'eyes/middle_left.png'
TIRED_RIGHT = _BASE_PATH + 'eyes/tired_right.png'
PINCHED_LEFT = _BASE_PATH + 'eyes/pinched_left.png'
PINCHED_MIDDLE = _BASE_PATH + 'eyes/pinched_middle.png'
CRAZY_1 = _BASE_PATH + 'eyes/crazy_1.png'
NEUTRAL = _BASE_PATH + 'eyes/neutral.png'
AWAKE = _BASE_PATH + 'eyes/awake.png'
UP = _BASE_PATH + 'eyes/up.png'
TIRED_LEFT = _BASE_PATH + 'eyes/tired_left.png'
ANGRY = _BASE_PATH + 'eyes/angry.png'
_BASE_PATH = "/usr/share/images/ev3dev/mono/"
RIGHT = _BASE_PATH + "information/right.png"
FORWARD = _BASE_PATH + "information/forward.png"
ACCEPT = _BASE_PATH + "information/accept.png"
QUESTION_MARK = _BASE_PATH + "information/question_mark.png"
STOP_1 = _BASE_PATH + "information/stop_1.png"
LEFT = _BASE_PATH + "information/left.png"
DECLINE = _BASE_PATH + "information/decline.png"
THUMBS_DOWN = _BASE_PATH + "information/thumbs_down.png"
BACKWARD = _BASE_PATH + "information/backward.png"
NO_GO = _BASE_PATH + "information/no_go.png"
WARNING = _BASE_PATH + "information/warning.png"
STOP_2 = _BASE_PATH + "information/stop_2.png"
THUMBS_UP = _BASE_PATH + "information/thumbs_up.png"
EV3 = _BASE_PATH + "lego/ev3.png"
EV3_ICON = _BASE_PATH + "lego/ev3_icon.png"
TARGET = _BASE_PATH + "objects/target.png"
BOTTOM_RIGHT = _BASE_PATH + "eyes/bottom_right.png"
BOTTOM_LEFT = _BASE_PATH + "eyes/bottom_left.png"
EVIL = _BASE_PATH + "eyes/evil.png"
CRAZY_2 = _BASE_PATH + "eyes/crazy_2.png"
KNOCKED_OUT = _BASE_PATH + "eyes/knocked_out.png"
PINCHED_RIGHT = _BASE_PATH + "eyes/pinched_right.png"
WINKING = _BASE_PATH + "eyes/winking.png"
DIZZY = _BASE_PATH + "eyes/dizzy.png"
DOWN = _BASE_PATH + "eyes/down.png"
TIRED_MIDDLE = _BASE_PATH + "eyes/tired_middle.png"
MIDDLE_RIGHT = _BASE_PATH + "eyes/middle_right.png"
SLEEPING = _BASE_PATH + "eyes/sleeping.png"
MIDDLE_LEFT = _BASE_PATH + "eyes/middle_left.png"
TIRED_RIGHT = _BASE_PATH + "eyes/tired_right.png"
PINCHED_LEFT = _BASE_PATH + "eyes/pinched_left.png"
PINCHED_MIDDLE = _BASE_PATH + "eyes/pinched_middle.png"
CRAZY_1 = _BASE_PATH + "eyes/crazy_1.png"
NEUTRAL = _BASE_PATH + "eyes/neutral.png"
AWAKE = _BASE_PATH + "eyes/awake.png"
UP = _BASE_PATH + "eyes/up.png"
TIRED_LEFT = _BASE_PATH + "eyes/tired_left.png"
ANGRY = _BASE_PATH + "eyes/angry.png"
+1 -1
View File
@@ -35,7 +35,7 @@ class Mailbox:
Returns:
The current value or ``None`` if the mailbox is empty.
"""
return ''
return ""
def send(self, value, brick=None):
"""Sends a value to this mailbox on connected devices.
+22 -18
View File
@@ -8,20 +8,20 @@ from enum import Enum as _Enum
class _PybricksEnumMeta(type(_Enum)):
def __dir__(cls):
yield '__class__'
yield '__name__'
yield "__class__"
yield "__name__"
for member in cls:
yield member.name
class _PybricksEnum(_Enum, metaclass=_PybricksEnumMeta):
def __dir__(self):
yield '__class__'
yield "__class__"
for member in type(self):
yield member.name
def __str__(self):
return '{}.{}'.format(type(self).__name__, self.name)
return "{}.{}".format(type(self).__name__, self.name)
def __repr__(self):
return str(self)
@@ -39,8 +39,12 @@ class Color:
return "Color(h={}, s={}, v={})".format(self.h, self.s, self.v)
def __eq__(self, other):
return (isinstance(other, Color) and
self.h == other.h and self.s == other.s and self.v == other.v)
return (
isinstance(other, Color)
and self.h == other.h
and self.s == other.s
and self.v == other.v
)
def __mul__(self, scale):
v = max(0, min(self.v * scale, 100))
@@ -50,10 +54,10 @@ class Color:
return self.__mul__(scale)
def __truediv__(self, scale):
return self.__mul__(1/scale)
return self.__mul__(1 / scale)
def __floordiv__(self, scale):
return self.__mul__(1/scale)
return self.__mul__(1 / scale)
Color.NONE = Color(0, 0, 0)
@@ -75,18 +79,18 @@ class Port(_PybricksEnum):
"""Port on the programmable brick or hub."""
# Generic motor/sensor ports
A = ord('A')
B = ord('B')
C = ord('C')
D = ord('D')
E = ord('E')
F = ord('F')
A = ord("A")
B = ord("B")
C = ord("C")
D = ord("D")
E = ord("E")
F = ord("F")
# NXT/EV3 sensor ports
S1 = ord('1')
S2 = ord('2')
S3 = ord('3')
S4 = ord('4')
S1 = ord("1")
S2 = ord("2")
S3 = ord("3")
S4 = ord("4")
class Stop(_PybricksEnum):
+20 -17
View File
@@ -5,9 +5,14 @@
from typing import Optional
from ._common import (Keypad as _Keypad, DCMotor as _DCMotor,
ColorLight as _ColorLight, Motor as _Motor,
LightArray as _LightArray, Light as _Light)
from ._common import (
Keypad as _Keypad,
DCMotor as _DCMotor,
ColorLight as _ColorLight,
Motor as _Motor,
LightArray as _LightArray,
Light as _Light,
)
from .parameters import Direction as _Direction, Button as _Button
@@ -37,15 +42,17 @@ class Remote:
"""LEGO® Powered Up Bluetooth Remote Control."""
light = _ColorLight()
buttons = _Keypad((
_Button.LEFT_MINUS,
_Button.RIGHT_MINUS,
_Button.LEFT,
_Button.CENTER,
_Button.RIGHT,
_Button.LEFT_PLUS,
_Button.RIGHT_PLUS
))
buttons = _Keypad(
(
_Button.LEFT_MINUS,
_Button.RIGHT_MINUS,
_Button.LEFT,
_Button.CENTER,
_Button.RIGHT,
_Button.LEFT_PLUS,
_Button.RIGHT_PLUS,
)
)
def __init__(self, name=None, timeout=10000):
"""When you instantiate this class, the hub will search for a remote
@@ -186,11 +193,7 @@ class PFMotor(DCMotor):
"""Control Power Functions motors with the infrared functionality of the
:class:`ColorDistanceSensor <pybricks.pupdevices.ColorDistanceSensor>`."""
def __init__(self,
sensor,
channel,
color,
positive_direction=_Direction.CLOCKWISE):
def __init__(self, sensor, channel, color, positive_direction=_Direction.CLOCKWISE):
"""
Arguments:
+3 -2
View File
@@ -51,8 +51,9 @@ class StopWatch:
class DataLog:
"""Create a file and log data."""
def __init__(self, *headers, name='log', timestamp=True, extension='csv',
append=False):
def __init__(
self, *headers, name="log", timestamp=True, extension="csv", append=False
):
"""
Arguments: