Skip to content

Commit 1fbb758

Browse files
docs: Add was_touched() & get_touches() for pins 0, 1, 2, pin_logo.
1 parent 0acb4ec commit 1fbb758

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

docs/microbit_micropython_api.rst

+15-4
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,29 @@ 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
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()
155+
# Only available for touch pins 0, 1, and 2. Returns the running total of
156+
# pin touches, and resets this counter to zero
157+
pin.get_touches()
158+
# Only available for touch pins 0, 1, and 2. Sets the touch mode.
159+
# Value can be either RESISTIVE or CAPACITIVE
154160
pin.set_touch_mode(value)
155161

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

158164
pin_logo::
159165

160-
# returns boolean for logo touch pin
166+
# returns a boolean for logo touch pin
161167
pin_logo.is_touched()
168+
# returns a boolean if the logo was pressed since the last time
169+
# this method was called
170+
pin_logo.was_touched()
171+
# returns the running total of touches, and resets this counter to zero
172+
pin_logo.get_touches()
162173
# Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE
163-
pin.set_touch_mode(value)
174+
pin_logo.set_touch_mode(value)
164175

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

docs/pin.rst

+10
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ its own to that.
202202
Return ``True`` if the pin is being touched with a finger, otherwise
203203
return ``False``.
204204

205+
.. py:method:: was_touched()
206+
207+
Returns ``True`` or ``False`` to indicate if the pin was touched
208+
since the device started or since the last time this method was called.
209+
210+
.. py:method:: get_touches()
211+
212+
Returns the number of times the pin was touched
213+
since the device started or since the last time this method was called.
214+
205215
.. py:method:: set_touch_mode(value)
206216
207217
.. note::

0 commit comments

Comments
 (0)