diff --git a/doc/api/iodevices_ev3.inc b/doc/api/iodevices_ev3.inc index 0fd269c..bc43735 100644 --- a/doc/api/iodevices_ev3.inc +++ b/doc/api/iodevices_ev3.inc @@ -77,31 +77,25 @@ This class can be used to control classic LEGO motors using converter cables. Ev3dev sensors ^^^^^^^^^^^^^^^^^^^^^ -EV3 MicroPython is built on top of ev3dev, which means that a particular sensor -may be supported even if it is not listed in this documentation. To test whether -your sensor is supported: +EV3 MicroPython is built on top of ev3dev, which means that a sensor +may be supported even if it is not listed in this documentation. If so, you can +use it with the ``Ev3devSensor`` class. This is easier and faster than using +the custom device classes given above. + +To check whether you can use the ``Ev3devSensor`` class: * Plug the sensor into your EV3 Brick. * Go to the main menu of the EV3 Brick. * Select `Device Browser` and then `Sensors`. - * If your sensor shows up, it is supported. + * If your sensor shows up, you can use it. -You will be able to use this sensor using the ``Ev3devSensor`` class below. -This lets you read the sensor values for a given mode number. To see which modes -are available for your sensor: +Now select your sensor from the menu and choose `set mode`. This shows all +available modes for this sensor. You can use these mode names as the ``mode`` +setting below. - * Follow the steps above and select your sensor. - * Select `set mode`. This shows all available modes for this sensor. - * You don't need to set a mode now, so press the back button to cancel. - -To read values in your program, enter the mode number as the ``mode`` setting -in the class shown below. The first mode is mode 0, the second mode is mode 1, -and so on. To learn more about compatible devices and their modes, visit the -`ev3dev sensors`_ page. +To learn more about compatible devices and what each mode does, +visit the `ev3dev sensors`_ page. .. _ev3dev sensors: http://docs.ev3dev.org/projects/lego-linux-drivers/en/ev3dev-stretch/sensors.html .. autoclass:: pybricks.iodevices.Ev3devSensor - :no-members: - - .. automethod:: pybricks.iodevices.Ev3devSensor.read diff --git a/pybricks/iodevices.py b/pybricks/iodevices.py index 5daf82e..2706c84 100644 --- a/pybricks/iodevices.py +++ b/pybricks/iodevices.py @@ -34,8 +34,27 @@ class LUMPDevice(): pass -class Ev3devSensor(LUMPDevice): - pass +class Ev3devSensor(): + """Read values with an ev3dev-compatible sensor.""" + + def __init__(self, port): + """ + + Arguments: + port (Port): Port to which the device is connected. + """ + pass + + def read(self, mode): + """Read values at a given mode. + + Arguments: + mode (``str``): Mode name. + + Returns: + ``tuple``: Values read from the sensor. + """ + pass class AnalogSensor():