From d66e18b1135c7a1d04390c8b64ff59e957a4f5ed Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Wed, 1 Jul 2020 13:33:01 +0200 Subject: [PATCH] api/pupdevices: add TiltSensor This class and its methods are subject to change when the complete API for IMUs is introduced. --- doc/api/pupdevices.rst | 20 ++++++++++++-------- pybricks/pupdevices.py | 14 +++++++++++--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/doc/api/pupdevices.rst b/doc/api/pupdevices.rst index 3e1bae1..91f8442 100644 --- a/doc/api/pupdevices.rst +++ b/doc/api/pupdevices.rst @@ -205,19 +205,23 @@ Infrared Sensor .. automethod:: pybricks.pupdevices.InfraredSensor.count -.. Tilt Sensor -.. ^^^^^^^^^^^^^^^^^^^^^^^^^ +Tilt Sensor +^^^^^^^^^^^^^^^^^^^^^^^^^ -.. .. autoclass:: pybricks.pupdevices.TiltSensor +.. figure:: ../api/images/sensor_tilt.png + :width: 35 % + + +.. autoclass:: pybricks.pupdevices.TiltSensor :no-members: - .. automethod:: neutral - - .. automethod:: acceleration - .. automethod:: tilt - .. automethod:: up +.. .. automethod:: neutral + +.. .. automethod:: acceleration + +.. .. automethod:: up .. Remote Control diff --git a/pybricks/pupdevices.py b/pybricks/pupdevices.py index 4f296bc..dec45af 100644 --- a/pybricks/pupdevices.py +++ b/pybricks/pupdevices.py @@ -3,7 +3,7 @@ """LEGO® Powered Up motor, sensors, and lights.""" -from ._common import (KeyPad as _KeyPad, Accelerometer as _Accelerometer, +from ._common import (KeyPad as _KeyPad, ColorLight as _ColorLight, Motor as _Motor, LightArray as _LightArray, Light as _Light) @@ -43,17 +43,25 @@ class RemoteControl: pass -class TiltSensor(_Accelerometer): +class TiltSensor: """LEGO® Powered Up Tilt Sensor.""" def __init__(self, port): - """TiltSensor(port) + """ Arguments: port (Port): Port to which the sensor is connected. """ pass + def tilt(self): + """Measures the tilt relative to the horizontal plane. + + Returns: + (:ref:`angle`, :ref:`angle`): Tuple of pitch and roll angles. + """ + pass + class ColorDistanceSensor: """LEGO® Powered Up Color and Distance Sensor."""