Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uBit.io.logo might need to be configured as capacitive mode on startup #168

Closed
microbit-carlos opened this issue Feb 26, 2024 · 6 comments
Closed
Labels
Milestone

Comments

@microbit-carlos
Copy link
Contributor

It's possible that with the move to uBit.io.logo the default NRF52Pin touch mode is resistive and it might need to be set up to capacitive on startup.

With the latest commit in main, running this code and touching the logo is only registered if I am touching the GND pin as well:

from microbit import *
while True:
    print(pin_logo.is_touched())
    sleep(200)
@microbit-carlos
Copy link
Contributor Author

There might be some technical reason why Capacitive might or might not be the default for uBit.io.logo, which we'll need to discuss in:

In the meantime I think we can probably change the mode in the MicroPython side, and if the default changes in the future we can revert it later.

@dpgeorge
Copy link
Collaborator

Actually, the problem here is a bit subtle. uBit.io.logo is already of type NRF52Pin and MicroPython is calling NRF52Pin::wasTouched() to get touch information for the pin_logo.was_touched() method. That function's signature is:

int wasTouched( TouchMode touchMode = TouchMode::Capacitative );

So we are already using capacitive touch for pin_logo.was_touched(). Just not pin_logo.is_touched().

If you first run pin_logo.was_touched() it will configure it to capacitive, and then pin_logo.is_touched() actually works in touch mode!

@dpgeorge
Copy link
Collaborator

My above statement seems to be true for all pins, not just pin_logo. Eg, run the above while-True loop using pin0 and then run pin0.was_touched() and then run the loop again. The second time the pin seems much more responsive.

@dpgeorge
Copy link
Collaborator

In 3074c81 I made pin_logo capacitive at start up.

The remaining thing to do is fix CODAL so that calling wasTouched() without any arguments doesn't change the pin mode.

@dpgeorge dpgeorge removed their assignment Mar 25, 2024
@microbit-carlos
Copy link
Contributor Author

Thanks Damien, once we resolve lancaster-university/codal-microbit-v2#411 in CODAL we can also revert that change.
wasTouched() is tracked in:

microbit-carlos added a commit that referenced this issue Aug 6, 2024
Removed workaround needed before CODAL set the uBit.io.logo touch
mode to capacitive by default.
Discussion:
#168

CODAL changelog:
https://github.com/lancaster-university/codal-microbit-v2/blob/master/Changelog.md#v0267
dpgeorge pushed a commit that referenced this issue Aug 7, 2024
Removed workaround needed before CODAL set the uBit.io.logo touch
mode to capacitive by default.
Discussion:
#168

CODAL changelog:
https://github.com/lancaster-university/codal-microbit-v2/blob/master/Changelog.md#v0267
@microbit-carlos
Copy link
Contributor Author

Workaround removed in #213.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants