mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
api/nxtdevices: add VernierAdapter
This commit is contained in:
@@ -54,3 +54,14 @@ NXT Temperature Sensor
|
||||
NXT Energy Meter
|
||||
^^^^^^^^^^^^^^^^^
|
||||
.. autoclass:: pybricks.nxtdevices.EnergyMeter
|
||||
|
||||
Vernier Adapter
|
||||
^^^^^^^^^^^^^^^^^
|
||||
.. autoclass:: pybricks.nxtdevices.VernierAdapter
|
||||
|
||||
.. toggle-header::
|
||||
:header: **Show/hide example**
|
||||
|
||||
**Example: Using the Surface Temperature Sensor.**
|
||||
|
||||
.. literalinclude:: ../../pybricks-projects/snippets/ev3/vernier_surface_temperature/main.py
|
||||
|
||||
+1
-1
Submodule pybricks-projects updated: 5ffedc9d51...a18ba6499c
@@ -1,6 +1,9 @@
|
||||
"""Use LEGO® MINDSTORMS® NXT motors and sensors with the EV3 brick."""
|
||||
|
||||
|
||||
from pybricks.iodevices import AnalogSensor
|
||||
|
||||
|
||||
class TouchSensor():
|
||||
"""LEGO® MINDSTORMS® NXT Touch Sensor."""
|
||||
|
||||
@@ -221,3 +224,52 @@ class EnergyMeter():
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class VernierAdapter(AnalogSensor):
|
||||
"""LEGO® MINDSTORMS® Education NXT/EV3 Adapter for Vernier Sensors."""
|
||||
|
||||
def __init__(self, port, conversion=None):
|
||||
"""
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
conversion (callable): Function of the format :meth:`.conversion`.
|
||||
This function is used to convert the raw analog voltage to the
|
||||
sensor-specific output value. Each Vernier Sensor has its
|
||||
own conversion function. The example given below demonstrates
|
||||
the conversion for the Surface Temperature Sensor.
|
||||
"""
|
||||
pass
|
||||
|
||||
def voltage(self):
|
||||
"""Measure the raw analog sensor voltage.
|
||||
|
||||
Returns:
|
||||
:ref:`voltage`: Analog voltage.
|
||||
"""
|
||||
pass
|
||||
|
||||
def conversion(self, voltage):
|
||||
"""User-supplied function that converts the raw voltage (mV) to a
|
||||
sensor value.
|
||||
|
||||
If you did not provide a ``conversion`` function earlier, no conversion
|
||||
will be applied.
|
||||
|
||||
Arguments:
|
||||
voltage (:ref:`voltage`): Analog sensor voltage
|
||||
|
||||
:returns: Converted sensor value.
|
||||
:rtype: float
|
||||
"""
|
||||
pass
|
||||
|
||||
def value(self):
|
||||
"""This method measures the sensor :meth:`.voltage` and then
|
||||
applies your :meth:`.conversion` to give you the sensor value.
|
||||
|
||||
:returns: Converted sensor value.
|
||||
:rtype: float
|
||||
"""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user