Skip to content

Commit 828de9a

Browse files
docs: Add was_touched method for pins 0,1,2 & pin_logo.
1 parent acee09a commit 828de9a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/microbit_micropython_api.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ 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, and 2. Returns boolean if the pin
153+
# has been touched since the last time this method was called
154+
pin.was_touched()
152155
# Only available for touch pins 0, 1, 2 and on micro:bit V2 also the logo.
153156
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
154157
pin.set_touch_mode(value)
@@ -157,8 +160,11 @@ Except in the case of the pins marked **V2**, which offers the following API:
157160

158161
pin_logo::
159162

160-
# returns boolean for logo touch pin
163+
# returns a boolean for logo touch pin
161164
pin_logo.is_touched()
165+
# returns a boolean if the logo was pressed since the last time
166+
# this method was called
167+
pin_logo.was_touched()
162168
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
163169
pin.set_touch_mode(value)
164170

docs/pin.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ its own to that.
218218
<https://www.allaboutcircuits.com/technical-articles/introduction-to-capacitive-touch-sensing>`_
219219
does not require you to make a ground connection as part of a circuit.
220220

221+
.. py:method:: was_touched()
222+
223+
Returns ``True`` or ``False`` to indicate if the pin was touched
224+
since the device started or since the last time this method was called.
225+
221226
.. py:method:: set_touch_mode(value)
222227
223228
.. note::

0 commit comments

Comments
 (0)