From 828de9afdb56b3fb17b2a178d084caf6a4dd2fd9 Mon Sep 17 00:00:00 2001 From: Carlos Pereira Atencio Date: Mon, 4 Mar 2024 16:41:58 +0000 Subject: [PATCH] docs: Add was_touched method for pins 0,1,2 & pin_logo. --- docs/microbit_micropython_api.rst | 8 +++++++- docs/pin.rst | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/microbit_micropython_api.rst b/docs/microbit_micropython_api.rst index 19362fdac..0e1bd3d97 100644 --- a/docs/microbit_micropython_api.rst +++ b/docs/microbit_micropython_api.rst @@ -149,6 +149,9 @@ 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, and 2. Returns boolean if the pin + # has been touched since the last time this method was called + pin.was_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) @@ -157,8 +160,11 @@ Except in the case of the pins marked **V2**, which offers the following API: pin_logo:: - # returns boolean for logo touch pin + # returns a boolean for logo touch pin pin_logo.is_touched() + # returns a boolean if the logo was pressed since the last time + # this method was called + pin_logo.was_touched() # Sets the touch mode. Value can be either RESISTIVE or CAPACITIVE pin.set_touch_mode(value) diff --git a/docs/pin.rst b/docs/pin.rst index 3cf539d0d..5134fb2f6 100644 --- a/docs/pin.rst +++ b/docs/pin.rst @@ -218,6 +218,11 @@ its own to that. `_ does not require you to make a ground connection as part of a circuit. + .. py:method:: was_touched() + + Returns ``True`` or ``False`` to indicate if the pin was touched + since the device started or since the last time this method was called. + .. py:method:: set_touch_mode(value) .. note::