Skip to content

Add set and get touch modes for touch pins #14

Closed
@microbit-carlos

Description

@microbit-carlos
Contributor

To be able to set and get the touch model for the logo and touch pins, between capacitive and resistive.

The default modes should be (I believe this part is implemented already):

  • Logo touch will be default to capacitive
  • Edge connector pins will be resistive

Activity

added this to the 2.0.0-beta.1 milestone on Nov 13, 2020
jaustin

jaustin commented on Nov 13, 2020

@jaustin
Contributor

The uBit object already constructs these with the appropriate defaults, but there should be a way to switch them over to the other modes. This is done in CODAL by calling isTouched() with an argument to determine the mode

https://github.com/lancaster-university/codal-nrf52/blob/master/source/NRF52Pin.cpp#L520

Here's usage in MakeCode...
https://github.com/microsoft/pxt-microbit/blob/master/libs/core/touchmode.cpp#L40

Pins that can have their touchmode changed

  • logo
  • P0
  • P1
  • P2

(this list is defined by the hardware because these pins have 10M pullups that make the resistive mode work)

logo is it's own class with only `is_touched()' so that needs extending, as do pin0,1,2

Proposed Python API:

pin0.set_touch_mode(pin0.CAPACITIVE)
pin_logo.set_touch_mode(pin_logo.RESISTIVE)
removed this from the 2.0.0-beta.1 milestone on Nov 13, 2020
added this to the 2.0.0-beta.2 milestone on Nov 25, 2020
dpgeorge

dpgeorge commented on Dec 21, 2020

@dpgeorge
Collaborator

pin.set_touch_mode(mode) method and corresponding constants were added in cbc3cfc

microbit-carlos

microbit-carlos commented on Dec 21, 2020

@microbit-carlos
ContributorAuthor

Gave this a test and all looks good, thanks Damien!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jaustin@dpgeorge@microbit-carlos

        Issue actions

          Add set and get touch modes for touch pins · Issue #14 · microbit-foundation/micropython-microbit-v2