diff --git a/doc/api/iodevices_ev3.inc b/doc/api/iodevices_ev3.inc index 552bb30..674a77a 100644 --- a/doc/api/iodevices_ev3.inc +++ b/doc/api/iodevices_ev3.inc @@ -67,14 +67,14 @@ DC Motor This class can be used to control classic LEGO motors using converter cables. -.. autoclass:: pybricks.builtins.DCMotor +.. autoclass:: pybricks._common.DCMotor :noindex: :no-members: - .. automethod:: pybricks.builtins.DCMotor.dc + .. automethod:: pybricks._common.DCMotor.dc :noindex: - .. automethod:: pybricks.builtins.DCMotor.stop + .. automethod:: pybricks._common.DCMotor.stop :noindex: Ev3dev sensors diff --git a/doc/api/motors.rst b/doc/api/motors.rst index 65da141..3cb4625 100644 --- a/doc/api/motors.rst +++ b/doc/api/motors.rst @@ -117,21 +117,21 @@ you can set the settings at the beginning of your program. Alternatively, first call ``stop()`` to make your ``Motor`` or ``DriveBase`` stop, and then change the settings. -.. autoclass:: pybricks.builtins.Control +.. autoclass:: pybricks._common.Control :no-members: .. rubric:: Status - .. automethod:: pybricks.builtins.Control.done + .. automethod:: pybricks._common.Control.done - .. automethod:: pybricks.builtins.Control.stalled + .. automethod:: pybricks._common.Control.stalled .. rubric:: Settings - .. automethod:: pybricks.builtins.Control.limits + .. automethod:: pybricks._common.Control.limits - .. automethod:: pybricks.builtins.Control.pid + .. automethod:: pybricks._common.Control.pid - .. automethod:: pybricks.builtins.Control.target_tolerances + .. automethod:: pybricks._common.Control.target_tolerances - .. automethod:: pybricks.builtins.Control.stall_tolerances + .. automethod:: pybricks._common.Control.stall_tolerances diff --git a/doc/api/pupdevices.rst b/doc/api/pupdevices.rst index 72b7501..50822b5 100644 --- a/doc/api/pupdevices.rst +++ b/doc/api/pupdevices.rst @@ -7,17 +7,17 @@ Motors without Rotation Sensors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. autoclass:: pybricks.builtins.DCMotor +.. autoclass:: pybricks._common.DCMotor :noindex: :no-members: - .. automethod:: pybricks.builtins.DCMotor.dc + .. automethod:: pybricks._common.DCMotor.dc :noindex: - .. automethod:: pybricks.builtins.DCMotor.stop + .. automethod:: pybricks._common.DCMotor.stop :noindex: - .. automethod:: pybricks.builtins.DCMotor.brake + .. automethod:: pybricks._common.DCMotor.brake :noindex: Motors with Rotation Sensors diff --git a/doc/common/conf.py b/doc/common/conf.py index 0031b71..40c0b49 100644 --- a/doc/common/conf.py +++ b/doc/common/conf.py @@ -34,7 +34,7 @@ sys.path.insert(0, TOP_DIR) from pybricks.hubs import EV3Brick # noqa E402 from pybricks.media.ev3dev import Image # noqa E402 -from pybricks.builtins import Speaker # noqa E402 +from pybricks._common import Speaker # noqa E402 # ON_RTD is whether we are on readthedocs.org # this line of code grabbed from docs.readthedocs.org diff --git a/pybricks/builtins.py b/pybricks/_common.py similarity index 100% rename from pybricks/builtins.py rename to pybricks/_common.py diff --git a/pybricks/ev3devices.py b/pybricks/ev3devices.py index a3f7aa9..5b83a36 100644 --- a/pybricks/ev3devices.py +++ b/pybricks/ev3devices.py @@ -3,8 +3,8 @@ """LEGO® MINDSTORMS® EV3 motors and sensors.""" -from .parameters import Direction -from .builtins import Motor # noqa E402 +from .parameters import Direction as _Direction +from ._common import Motor # noqa E402 class TouchSensor: @@ -153,7 +153,7 @@ class InfraredSensor: class GyroSensor: """LEGO® MINDSTORMS® EV3 Gyro Sensor.""" - def __init__(self, port, positive_direction=Direction.CLOCKWISE): + def __init__(self, port, positive_direction=_Direction.CLOCKWISE): """ Arguments: diff --git a/pybricks/hubs.py b/pybricks/hubs.py index e404f3d..ba27612 100644 --- a/pybricks/hubs.py +++ b/pybricks/hubs.py @@ -2,26 +2,27 @@ # Copyright (c) 2018-2020 The Pybricks Authors """LEGO® Programmable Hubs.""" -from .builtins import Speaker, Battery, ColorLight, KeyPad -from .media.ev3dev import Image +from ._common import (Speaker as _Speaker, Battery as _Battery, + ColorLight as _ColorLight, KeyPad as _KeyPad) +from .media.ev3dev import Image as _Image class EV3Brick: """LEGO® MINDSTORMS® EV3 Brick.""" - screen = Image('_screen_') - speaker = Speaker() - battery = Battery() - light = ColorLight() - buttons = KeyPad() + screen = _Image('_screen_') + speaker = _Speaker() + battery = _Battery() + light = _ColorLight() + buttons = _KeyPad() class MoveHub: """LEGO® Powered Up Move Hub.""" - battery = Battery() - light = ColorLight() + battery = _Battery() + light = _ColorLight() class CityHub: """LEGO® Powered Up City Hub.""" - battery = Battery() - light = ColorLight() + battery = _Battery() + light = _ColorLight() diff --git a/pybricks/media/ev3dev.py b/pybricks/media/ev3dev.py index 8e77d39..feb7f0f 100644 --- a/pybricks/media/ev3dev.py +++ b/pybricks/media/ev3dev.py @@ -3,7 +3,7 @@ """Images and Sounds for Pybricks on ev3dev.""" -from ..parameters import Color +from ..parameters import Color as _Color class Image: @@ -57,7 +57,7 @@ class Image: """ pass - def draw_pixel(self, x, y, color=Color.BLACK): + def draw_pixel(self, x, y, color=_Color.BLACK): """Draws a single pixel on |this image|. Arguments: @@ -67,7 +67,7 @@ class Image: """ pass - def draw_line(self, x1, y1, x2, y2, width=1, color=Color.BLACK): + def draw_line(self, x1, y1, x2, y2, width=1, color=_Color.BLACK): """Draws a line on |this image|. Arguments: @@ -80,7 +80,7 @@ class Image: """ pass - def draw_box(self, x1, y1, x2, y2, r=0, fill=False, color=Color.BLACK): + def draw_box(self, x1, y1, x2, y2, r=0, fill=False, color=_Color.BLACK): """Draws a box on |this image|. Arguments: @@ -95,7 +95,7 @@ class Image: """ pass - def draw_circle(self, x, y, r=0, fill=False, color=Color.BLACK): + def draw_circle(self, x, y, r=0, fill=False, color=_Color.BLACK): """Draws a circle on |this image|. Arguments: @@ -134,7 +134,7 @@ class Image: the ``source`` image is loaded from file. """ - def draw_text(self, x, y, text, text_color=Color.BLACK, background_color=None): + def draw_text(self, x, y, text, text_color=_Color.BLACK, background_color=None): """Draws text on |this image|. The most recent font set using :meth:`set_font` will be used or diff --git a/pybricks/nxtdevices.py b/pybricks/nxtdevices.py index 1515e79..2cc5483 100644 --- a/pybricks/nxtdevices.py +++ b/pybricks/nxtdevices.py @@ -4,8 +4,8 @@ """Use LEGO® MINDSTORMS® NXT motors and sensors with the EV3 brick.""" -from pybricks.iodevices import AnalogSensor -from pybricks.builtins import ColorLight +from .iodevices import AnalogSensor as _AnalogSensor +from ._common import ColorLight as _ColorLight class TouchSensor: @@ -65,7 +65,7 @@ class LightSensor: class ColorSensor: """LEGO® MINDSTORMS® NXT Color Sensor.""" - light = ColorLight() + light = _ColorLight() def __init__(self, port): """ @@ -242,7 +242,7 @@ class EnergyMeter: pass -class VernierAdapter(AnalogSensor): +class VernierAdapter(_AnalogSensor): """LEGO® MINDSTORMS® Education NXT/EV3 Adapter for Vernier Sensors.""" def __init__(self, port, conversion=None): diff --git a/pybricks/parameters.py b/pybricks/parameters.py index 01b532e..ade3144 100644 --- a/pybricks/parameters.py +++ b/pybricks/parameters.py @@ -3,10 +3,10 @@ """Constant parameters/arguments for the Pybricks API.""" -from enum import Enum +from enum import Enum as _Enum -class _PybricksEnumMeta(type(Enum)): +class _PybricksEnumMeta(type(_Enum)): def __dir__(cls): yield '__class__' yield '__name__' @@ -14,7 +14,7 @@ class _PybricksEnumMeta(type(Enum)): yield member.name -class _PybricksEnum(Enum, metaclass=_PybricksEnumMeta): +class _PybricksEnum(_Enum, metaclass=_PybricksEnumMeta): def __dir__(self): yield '__class__' for member in type(self): diff --git a/pybricks/pupdevices.py b/pybricks/pupdevices.py index ca1e088..697b95f 100644 --- a/pybricks/pupdevices.py +++ b/pybricks/pupdevices.py @@ -3,10 +3,11 @@ """LEGO® Powered Up motor, sensors, and lights.""" -from .builtins import KeyPad, Accelerometer, ColorLight, Motor +from ._common import (KeyPad as _KeyPad, Accelerometer as _Accelerometer, + ColorLight as _ColorLight, Motor as _Motor) -class Motor(Motor): +class Motor(_Motor): """Generic class to control motors with built-in rotation sensors.""" def reset_angle(self, angle=None): @@ -24,8 +25,8 @@ class Motor(Motor): class RemoteControl: """LEGO® Powered Up Bluetooth Remote Control/Handset.""" - light = ColorLight() - buttons = KeyPad() + light = _ColorLight() + buttons = _KeyPad() def __init__(self, device=None, timeout=10000): """Connect the handset to the hub. @@ -41,7 +42,7 @@ class RemoteControl: pass -class TiltSensor(Accelerometer): +class TiltSensor(_Accelerometer): """LEGO® Powered Up Tilt Sensor.""" def __init__(self, port): @@ -56,7 +57,7 @@ class TiltSensor(Accelerometer): class ColorDistanceSensor: """LEGO® Powered Up Color and Distance Sensor.""" - light = ColorLight() + light = _ColorLight() def __init__(self, port): """ColorDistanceSensor(port) diff --git a/pybricks/robotics.py b/pybricks/robotics.py index 52328c0..11e08ca 100644 --- a/pybricks/robotics.py +++ b/pybricks/robotics.py @@ -3,19 +3,19 @@ """Robotics module for the Pybricks API.""" -from .builtins import Control +from ._common import Control as _Control class DriveBase: """A robotic vehicle with two powered wheels and an optional support wheel or caster.""" - distance_control = Control() + distance_control = _Control() """The traveled distance and drive speed are controlled by a PID controller. You can use this attribute to change its settings. See :ref:`control` for an overview of available methods.""" - heading_control = Control() + heading_control = _Control() """The robot turn angle and turn rate are controlled by a PID controller. You can use this attribute to change its settings. See :ref:`control` for an overview of available methods."""