Skip to content

Commit 7c15699

Browse files
microbit-markmicrobit-carlos
authored andcommitted
V2 docs: Add pin set_touch_mode() (#701)
* V2 docs: add set_touch_mode() * V2 docs: add set_touch_mode() to micropython API doc
1 parent 9b22b29 commit 7c15699

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

docs/microbit_micropython_api.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ Provide digital and analog input and output functionality, for the pins in the
112112
connector, the **V2** logo and the **V2** speaker. Some pins are connected
113113
internally to the I/O that drives the LED matrix and the buttons.
114114

115-
Each pin is provided as an object directly in the ``microbit`` module. This keeps the API relatively flat, making it very easy to use:
115+
Each pin is provided as an object directly in the ``microbit`` module. This
116+
keeps the API relatively flat, making it very easy to use:
116117

117118
* pin0
118119
* pin1
@@ -144,13 +145,18 @@ Each of these pins are instances of the ``MicroBitPin`` class, which offers the
144145
# Only available for touch pins 0, 1, and 2. Returns boolean if the pin
145146
# is touched
146147
pin.is_touched()
148+
# Only available for touch pins 0, 1, 2 and on micro:bit V2 also the logo.
149+
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
150+
pin.set_touch_mode(value)
147151

148152
Except in the case of the pins marked **V2**, which offers the following API:
149153

150154
pin_logo::
151155

152156
# returns boolean for logo touch pin
153157
pin_logo.is_touched()
158+
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
159+
pin.set_touch_mode(value)
154160

155161
pin_speaker, as the above ``MicroBitPin`` class, but does not include
156162
``pin.is_touched()``.

docs/pin.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ they are internally connected to. The pins are available as attributes on the
7373
| 20 | Digital | I2C SDA | I2C SDA |
7474
+-----+---------+----------+-----------------+
7575

76-
The above table summarizes the pins available, their types (see below) and what
77-
they are internally connected to.
78-
7976
The latest micro:bit device **V2** has two additional pins that you can access
8077
in MicroPython, but that are not available via the edge connector:
8178

@@ -207,7 +204,7 @@ its own to that.
207204
The default touch mode for the pins on the edge connector is
208205
`resistive`. The default for the logo pin **V2** is `capacitive`.
209206

210-
**Resitive touch**
207+
**Resistive touch**
211208
This test is done by measuring how much resistance there is between the
212209
pin and ground. A low resistance gives a reading of ``True``. To get
213210
a reliable reading using a finger you may need to touch the ground pin
@@ -218,6 +215,15 @@ its own to that.
218215
using a finger as a conductor. `Capacitive touch
219216
<https://www.allaboutcircuits.com/technical-articles/introduction-to-capacitive-touch-sensing>`_
220217
does not require you to make a ground connection as part of a circuit.
218+
219+
.. py:method:: set_touch_mode(value)
220+
221+
.. note::
222+
The default touch mode for the pins on the edge connector is
223+
`resistive`. The default for the logo pin **V2** is `capacitive`.
224+
225+
Set the touch mode for the given pin. Value can be either ``CAPACITIVE``
226+
or ``RESISTIVE``. For example, ``pin0.set_touch_mode(pin0.CAPACITIVE)``.
221227

222228
The pull mode for a pin is automatically configured when the pin changes to an
223229
input mode. Input modes are when you call ``read_analog`` / ``read_digital`` /

0 commit comments

Comments
 (0)