diff --git a/docs/microbit_micropython_api.rst b/docs/microbit_micropython_api.rst index 144928a3a..5354b7f45 100644 --- a/docs/microbit_micropython_api.rst +++ b/docs/microbit_micropython_api.rst @@ -112,7 +112,8 @@ Provide digital and analog input and output functionality, for the pins in the connector, the **V2** logo and the **V2** speaker. Some pins are connected internally to the I/O that drives the LED matrix and the buttons. -Each pin is provided as an object directly in the ``microbit`` module. This keeps the API relatively flat, making it very easy to use: +Each pin is provided as an object directly in the ``microbit`` module. This +keeps the API relatively flat, making it very easy to use: * pin0 * pin1 @@ -144,6 +145,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, 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:: @@ -151,6 +155,8 @@ 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: diff --git a/docs/pin.rst b/docs/pin.rst index 4813abe90..7641f7f4b 100644 --- a/docs/pin.rst +++ b/docs/pin.rst @@ -26,8 +26,9 @@ Pin Functions `Edge connector and pinout `_ -Those pins are available as attributes on the ``microbit`` -module:``microbit.pin0`` - ``microbit.pin20``. +This table summarises the pins available, their types and what +they are internally connected to. The pins are available as attributes on the +``microbit`` module: ``microbit.pin0`` - ``microbit.pin20``. +-----+---------+----------+-----------------+ | Pin | Type | Function | Function **V2** | @@ -72,9 +73,6 @@ module:``microbit.pin0`` - ``microbit.pin20``. | 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: @@ -212,7 +210,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 @@ -223,6 +221,15 @@ its own to that. using a finger as a conductor. `Capacitive touch `_ 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`` /