Skip to content

Commit d7cbd28

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 3837ea8 commit d7cbd28

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

docs/microbit_micropython_api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,18 @@ Each of these pins are instances of the ``MicroBitPin`` class, which offers the
149149
# Only available for touch pins 0, 1, and 2. Returns boolean if the pin
150150
# is touched
151151
pin.is_touched()
152+
# Only available for touch pins 0, 1, 2 and on micro:bit V2 also the logo.
153+
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
154+
pin.set_touch_mode(value)
152155

153156
Except in the case of the pins marked **V2**, which offers the following API:
154157

155158
pin_logo::
156159

157160
# returns boolean for logo touch pin
158161
pin_logo.is_touched()
162+
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
163+
pin.set_touch_mode(value)
159164

160165
pin_speaker, as the above ``MicroBitPin`` class, but does not include
161166
``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)