Skip to content

Commit

Permalink
V2 docs: Add pin set_touch_mode() (#701)
Browse files Browse the repository at this point in the history
* V2 docs: add set_touch_mode()

* V2 docs: add set_touch_mode() to micropython API doc
  • Loading branch information
microbit-mark authored and microbit-carlos committed Sep 16, 2024
1 parent 5357b8e commit f9a37b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/microbit_micropython_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,18 @@ Each of these pins are instances of the ``MicroBitPin`` class, which offers the
# Only available for touch pins 0, 1, and 2. Returns boolean if the pin
# is touched
pin.is_touched()
# Only available for touch pins 0, 1, 2 and on micro:bit V2 also the logo.
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
pin.set_touch_mode(value)

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

pin_logo::

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

pin_speaker, as the above ``MicroBitPin`` class, but does not include
``pin.is_touched()``.
Expand Down
14 changes: 10 additions & 4 deletions docs/pin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ they are internally connected to. The pins are available as attributes on the
| 20 | Digital | I2C SDA | I2C SDA |
+-----+---------+----------+-----------------+

The above table summarizes the pins available, their types (see below) and what
they are internally connected to.

The latest micro:bit device **V2** has two additional pins that you can access
in MicroPython, but that are not available via the edge connector:

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

**Resitive touch**
**Resistive touch**
This test is done by measuring how much resistance there is between the
pin and ground. A low resistance gives a reading of ``True``. To get
a reliable reading using a finger you may need to touch the ground pin
Expand All @@ -218,6 +215,15 @@ its own to that.
using a finger as a conductor. `Capacitive touch
<https://www.allaboutcircuits.com/technical-articles/introduction-to-capacitive-touch-sensing>`_
does not require you to make a ground connection as part of a circuit.

.. py:method:: set_touch_mode(value)
.. note::
The default touch mode for the pins on the edge connector is
`resistive`. The default for the logo pin **V2** is `capacitive`.

Set the touch mode for the given pin. Value can be either ``CAPACITIVE``
or ``RESISTIVE``. For example, ``pin0.set_touch_mode(pin0.CAPACITIVE)``.

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

0 comments on commit f9a37b4

Please sign in to comment.