Skip to content

Commit 338c48d

Browse files
WasabiFandwalton76
authored andcommitted
Add docs page on port name constants (#585)
1 parent e859d0e commit 338c48d

3 files changed

Lines changed: 60 additions & 11 deletions

File tree

docs/port-names.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. _port-names:
2+
3+
Port names
4+
==========
5+
6+
Classes such as :py:class:`ev3dev2.motor.Motor` and those based on
7+
:py:class:`ev3dev2.sensor.Sensor` accept parameters to specify which port the
8+
target device is connected to. This parameter is typically caled ``address``.
9+
10+
The following constants are available on all platforms:
11+
12+
.. rubric:: Output
13+
14+
- ``ev3dev2.motor.OUTPUT_A``
15+
- ``ev3dev2.motor.OUTPUT_B``
16+
- ``ev3dev2.motor.OUTPUT_C``
17+
- ``ev3dev2.motor.OUTPUT_D``
18+
19+
.. rubric:: Input
20+
21+
- ``ev3dev2.sensor.INPUT_1``
22+
- ``ev3dev2.sensor.INPUT_2``
23+
- ``ev3dev2.sensor.INPUT_3``
24+
- ``ev3dev2.sensor.INPUT_4``
25+
26+
Additionally, on BrickPi3, the ports of up to four stacked BrickPi's can be
27+
referenced as `OUTPUT_E` through `OUTPUT_P` and `INPUT_5` through `INPUT_16`.
28+
29+
.. rubric:: Example
30+
31+
.. code-block:: python
32+
33+
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B
34+
from ev3dev2.sensor import INPUT_1
35+
from ev3dev2.sensor.lego import TouchSensor
36+
37+
m = LargeMotor(OUTPUT_A)
38+
s = TouchSensor(INPUT_1)

docs/ports.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Lego Port
22
=========
33

4+
The `LegoPort` class is only needed when manually reconfiguring input/output
5+
ports. Most users can ignore this page.
6+
47
.. autoclass:: ev3dev2.port.LegoPort
58
:members:

docs/spec.rst

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
API reference
22
=============
33

4-
Each class in ev3dev module inherits from the base :py:class:`ev3dev2.Device` class.
5-
6-
.. autoclass:: ev3dev2.Device
7-
8-
.. autofunction:: ev3dev2.list_device_names
9-
10-
.. autofunction:: ev3dev2.list_devices
11-
12-
.. autofunction:: ev3dev2.motor.list_motors
13-
14-
.. autofunction:: ev3dev2.sensor.list_sensors
4+
Device interfaces
5+
-----------------
156

167
.. rubric:: Contents:
178

@@ -26,4 +17,21 @@ Each class in ev3dev module inherits from the base :py:class:`ev3dev2.Device` cl
2617
sound
2718
display
2819
ports
20+
port-names
2921
wheels
22+
23+
24+
Other APIs
25+
----------
26+
27+
Each class in ev3dev module inherits from the base :py:class:`ev3dev2.Device` class.
28+
29+
.. autoclass:: ev3dev2.Device
30+
31+
.. autofunction:: ev3dev2.list_device_names
32+
33+
.. autofunction:: ev3dev2.list_devices
34+
35+
.. autofunction:: ev3dev2.motor.list_motors
36+
37+
.. autofunction:: ev3dev2.sensor.list_sensors

0 commit comments

Comments
 (0)