From e67c048b18087781ba449220926ed9bdc2f3716e Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Fri, 22 May 2020 13:46:44 +0200 Subject: [PATCH] api/pupdevices: add UltrasonicSensor Initial class without any methods for the SPIKE Ultrasonic Sensor --- doc/api/pupdevices.rst | 27 ++++++++++++++++++++++++++- pybricks/pupdevices.py | 6 ++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/doc/api/pupdevices.rst b/doc/api/pupdevices.rst index 61322eb..f2a9427 100644 --- a/doc/api/pupdevices.rst +++ b/doc/api/pupdevices.rst @@ -121,6 +121,8 @@ Color Sensor .. todo:: Support for this sensor is not yet implemented. API is experimental. + Add image with numbered labels for light index + .. figure:: ../api/images/sensor_color.png :width: 35 % @@ -129,7 +131,7 @@ Color Sensor .. rubric:: Built-in lights - This sensor has a 3 built-in lights. You can adjust the brightness of each + This sensor has 3 built-in lights. You can adjust the brightness of each light. If you use the sensor to measure something afterwards, the light automatically turns back on as needed for the measurement. @@ -138,6 +140,29 @@ Color Sensor .. automethod:: pybricks.pupdevices::ColorSensor.lights.off +Ultrasonic Sensor +^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. todo:: Support for this sensor is not yet implemented. API is experimental. + + Flip image to ensure top/bottom left/right description is correct + +.. figure:: ../api/images/sensor_ultrasonic.png + :width: 35 % + +.. autoclass:: pybricks.pupdevices.UltrasonicSensor + :no-members: + + .. rubric:: Built-in lights + + This sensor has 4 built-in lights. You can adjust the brightness of each + light. + + .. automethod:: pybricks.pupdevices::UltrasonicSensor.lights.on + + .. automethod:: pybricks.pupdevices::UltrasonicSensor.lights.off + + .. Tilt Sensor .. ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/pybricks/pupdevices.py b/pybricks/pupdevices.py index 979850d..8b0880a 100644 --- a/pybricks/pupdevices.py +++ b/pybricks/pupdevices.py @@ -142,3 +142,9 @@ class ColorSensor: """LEGO® SPIKE Color Sensor.""" lights = _LightArray(3) + + +class UltrasonicSensor: + """LEGO® SPIKE Color Sensor.""" + + lights = _LightArray(3)