Skip to content

Commit

Permalink
pybricks.pupdevices.Remote: Add name().
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Jul 28, 2021
1 parent 1cf6f8d commit 8463206
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
7 changes: 1 addition & 6 deletions doc/main/pupdevices/remote.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ Remote Control
.. autoclass:: pybricks.pupdevices.Remote
:no-members:

.. autoattribute:: pybricks.pupdevices::Remote.address
:annotation:
.. automethod:: pybricks.pupdevices::Remote.name

.. automethod:: pybricks.pupdevices::Remote.light.on

.. automethod:: pybricks.pupdevices::Remote.light.off

.. automethod:: pybricks.pupdevices::Remote.buttons.pressed

.. note::

The ``light`` and ``address`` features are not yet supported.

Examples
-------------------

Expand Down
23 changes: 17 additions & 6 deletions src/pybricks/pupdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,30 @@ class Remote:
_Button.LEFT_PLUS,
_Button.RIGHT_PLUS
))
address = None
"""Bluetooth address of the remote, or ``None`` if it is not connected."""

def __init__(self, address=None, timeout=10000):
"""Connects to the remote.
def __init__(self, name=None, timeout=10000):
"""When you instantiate this class, the hub will search for a remote
and connect automatically.
The remote must be on and ready for a connection, as indicated by a
white blinking light.
Arguments:
device (str): Bluetooth address of the remote. If no address is
given, it connects to the first available remote that it finds.
name (str): Bluetooth name of the remote. If no name is given,
the hub connects to the first remote that it finds.
timeout (:ref:`time`): How long to search for the remote.
"""
pass

def name(self, name=None):

This comment has been minimized.

Copy link
@dlech

dlech Jul 28, 2021

Member

Should this use @overload?

This comment has been minimized.

Copy link
@laurensvalk

laurensvalk Jul 28, 2021

Author Member

I'd like to do that all in one go when we get to #61

"""Gets or sets the Bluetooth name of the remote.
If no name is given, this method returns the current name.
Arguments:
name (str): New Bluetooth name of the remote.

This comment has been minimized.

Copy link
@laurensvalk

laurensvalk Jul 28, 2021

Author Member

Would be good to say what the maximum length is.

This comment has been minimized.

Copy link
@dlech

dlech Jul 28, 2021

Member

Probably 14 ASCII characters. (I've never tried multi-byte UTF-8 characters, but theoretically that should work - just limited to 14 bytes rather than 14 characters).

This comment has been minimized.

Copy link
@laurensvalk

laurensvalk Jul 28, 2021

Author Member

Thanks, I'll add it. I noticed the LWP3 docs said 14 but I thought you probably have the tools to verify already up and running.

"""


class TiltSensor:
"""LEGO® Powered Up Tilt Sensor."""
Expand Down

0 comments on commit 8463206

Please sign in to comment.