mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
api/pupdevices/ForceSensor: add methods
This commit is contained in:
committed by
laurensvalk
parent
8273c00881
commit
e0ac54ec0a
@@ -119,8 +119,6 @@ Color and Distance Sensor
|
||||
Color Sensor
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. todo:: Support for this sensor is not yet implemented. API is experimental.
|
||||
|
||||
.. figure:: ../api/images/sensor_color_lights_label.png
|
||||
:width: 70 %
|
||||
|
||||
@@ -151,8 +149,6 @@ Color Sensor
|
||||
Ultrasonic Sensor
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. todo:: Support for this sensor is not yet implemented. API is experimental.
|
||||
|
||||
.. figure:: ../api/images/sensor_ultrasonic_lights_label.png
|
||||
:width: 80 %
|
||||
|
||||
@@ -175,14 +171,19 @@ Ultrasonic Sensor
|
||||
Force Sensor
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. todo:: Support for this sensor is not yet implemented. API is experimental.
|
||||
|
||||
.. figure:: ../api/images/sensor_force.png
|
||||
:width: 35 %
|
||||
|
||||
.. autoclass:: pybricks.pupdevices.ForceSensor
|
||||
:no-members:
|
||||
|
||||
.. automethod:: pybricks.pupdevices.ForceSensor.force
|
||||
|
||||
.. automethod:: pybricks.pupdevices.ForceSensor.distance
|
||||
|
||||
.. automethod:: pybricks.pupdevices.ForceSensor.pressed
|
||||
|
||||
.. automethod:: pybricks.pupdevices.ForceSensor.touched
|
||||
|
||||
.. Tilt Sensor
|
||||
.. ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
+56
-2
@@ -143,6 +143,15 @@ class ColorSensor:
|
||||
|
||||
lights = _LightArray(3)
|
||||
|
||||
def __init__(self, port):
|
||||
"""
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def color(self, illuminate=True):
|
||||
"""Scans the color of a surface or an external light source.
|
||||
|
||||
@@ -227,7 +236,7 @@ class UltrasonicSensor:
|
||||
lights = _LightArray(3)
|
||||
|
||||
def __init__(self, port):
|
||||
"""UltrasonicSensor(port)
|
||||
"""
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
@@ -267,4 +276,49 @@ class UltrasonicSensor:
|
||||
|
||||
class ForceSensor:
|
||||
"""LEGO® SPIKE Force Sensor."""
|
||||
pass
|
||||
|
||||
def __init__(self, port):
|
||||
"""
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
pass
|
||||
|
||||
def force(self):
|
||||
"""Measures the force exerted on the sensor.
|
||||
|
||||
Returns:
|
||||
:ref:`force`: Measured force (up to approximately 10.00 N).
|
||||
"""
|
||||
|
||||
def distance(self):
|
||||
"""Measures by how much the sensor button has moved.
|
||||
|
||||
Returns:
|
||||
:ref:`distance`: How much the sensor button has
|
||||
moved (up to approximately 8.00 mm).
|
||||
"""
|
||||
|
||||
def pressed(self, force=3):
|
||||
"""Checks if the sensor button is pressed.
|
||||
|
||||
Arguments:
|
||||
force (:ref:`force`): Minimum force to be considered pressed.
|
||||
|
||||
Returns:
|
||||
bool: ``True`` if the sensor is pressed, ``False`` if it is not.
|
||||
"""
|
||||
|
||||
def touched(self):
|
||||
"""Checks if the sensor is touched.
|
||||
|
||||
This is similar to :meth:`pressed`, but it detects slight movements of
|
||||
the button even when the measured force is still considered zero.
|
||||
|
||||
Returns:
|
||||
bool: ``True`` if the sensor is touched or pressed, ``False``
|
||||
if it is not.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user