From c2d2884794f49fe409eabdc64015f96ff6deab2e Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Tue, 29 Dec 2020 19:51:48 +0100 Subject: [PATCH] api/pupdevices/Remote: publish draft api --- doc/api/pupdevices/index.rst | 8 ++++++++ doc/api/pupdevices/remote.rst | 20 ++++++++++++++++++++ pybricks/pupdevices.py | 19 +++++++++---------- pybricks/pupdevices.pyi | 7 ++++--- 4 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 doc/api/pupdevices/remote.rst diff --git a/doc/api/pupdevices/index.rst b/doc/api/pupdevices/index.rst index d985232..5695c0e 100644 --- a/doc/api/pupdevices/index.rst +++ b/doc/api/pupdevices/index.rst @@ -18,6 +18,7 @@ ultrasonicsensor forcesensor light + remote .. class:: DCMotor :noindex: @@ -88,3 +89,10 @@ .. figure:: ../../api/images/light.png :width: 90 % :target: light.html + +.. class:: Remote + :noindex: + +.. figure:: ../../api/images/pupremote.png + :width: 50 % + :target: remote.html diff --git a/doc/api/pupdevices/remote.rst b/doc/api/pupdevices/remote.rst new file mode 100644 index 0000000..9988384 --- /dev/null +++ b/doc/api/pupdevices/remote.rst @@ -0,0 +1,20 @@ +Remote Control +^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. warning:: + + This remote is not yet supported. + Upvote `this issue `_ if + you want to see this happen. + +.. figure:: ../../api/images/pupremote.png + :width: 60 % + +.. autoclass:: pybricks.pupdevices.Remote + :no-members: + + .. automethod:: pybricks.pupdevices::Remote.light.on + + .. automethod:: pybricks.pupdevices::Remote.light.off + + .. automethod:: pybricks.pupdevices::Remote.buttons.pressed diff --git a/pybricks/pupdevices.py b/pybricks/pupdevices.py index 53ffd76..2607a17 100644 --- a/pybricks/pupdevices.py +++ b/pybricks/pupdevices.py @@ -25,22 +25,21 @@ class Motor(_Motor): pass -class RemoteControl: - """LEGO® Powered Up Bluetooth Remote Control/Handset.""" +class Remote: + """LEGO® Powered Up Bluetooth Remote Control.""" light = _ColorLight() buttons = _Keypad() + address = None + """Bluetooth address of the remote.""" - def __init__(self, device=None, timeout=10000): - """Connect the handset to the hub. + def __init__(self, address=None, timeout=10000): + """Connects to the remote. Arguments: - device (str): Bluetooth address of the handset (? TODO ?). - If you do not specify a device identifier, the hub will - attempt to pair with any handset that is currently in - advertising mode. - timeout (:ref:`time`): The amount of time before giving up - searching. + device (str): Bluetooth address of the remote. If no address is + given, it connects to the first available remote that it finds. + timeout (:ref:`time`): How long to search for the remote. """ pass diff --git a/pybricks/pupdevices.pyi b/pybricks/pupdevices.pyi index ceed267..7cb4ca7 100644 --- a/pybricks/pupdevices.pyi +++ b/pybricks/pupdevices.pyi @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2020 The Pybricks Authors -from typing import Collection, List, Optional, Tuple +from typing import Collection, List, Optional, Tuple, Union from ._common import Keypad, DCMotor, ColorLight, LightArray, Motor as BaseMotor, Light as BaseLight @@ -9,10 +9,11 @@ from .parameters import Color, Direction, Port class Motor(BaseMotor): ... -class RemoteControl: +class Remote: light: ColorLight buttons: Keypad - def __init__(self, device: str = None, timeout: int = 10000): ... + addresss: Union[str, None] + def __init__(self, address: str = None, timeout: int = 10000): ... class TiltSensor: def __init__(self, port: Port): ...