-
Notifications
You must be signed in to change notification settings - Fork 52
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
Should uBit.logo work when switched to TouchMode::Resistive? #113
Comments
I can confirm that In this example
The same can be replicated in MakeCode, as it uses input.onButtonPressed(Button.A, function () {
basic.showString("r")
pins.touchSetMode(TouchTarget.LOGO, TouchTargetMode.Resistive)
})
input.onButtonPressed(Button.B, function () {
basic.showString("c")
pins.touchSetMode(TouchTarget.LOGO, TouchTargetMode.Capacitive)
})
basic.forever(function () {
if (input.logoIsPressed()) {
basic.showIcon(IconNames.Heart)
} else {
basic.showIcon(IconNames.Sad)
}
}) MakeCode C++ code: |
MakeCode block "set logo to touch mode %mode" uses uBit.io.logo.isTouched(mode), but I don’t think uBit.logo supports changing the uBit.io.logo touch mode. uBit.logo is a TouchButton, whose NRF52Pin (uBit.io.logo) is initially set as output and monitored via GPIOTE events in NRF52TouchSensor (uBit.touchSensor). uBit.logo is not aware of changes to uBit.io.logo via NRF52Pin. Changing mode with uBit.io.logo.isTouched(Resistive) creates a Button, sets the pin to input, and sets its pull mode, which presumably clashes with the ongoing uBit.logo TouchButton and NRF52TouchSensor GPIOTE code. Changing mode with uBit.io.logo.isTouched(Capacitive) adds a second TouchButton to uBit.touchSensor, and sets the pin as output again. After that, uBit.logo.isPressed() seems to start working again, though I think it no longer has the “empty timeslot for that channel to drain all its charge before sampling it again”, and MakeCode’s “on logo pressed” block sees double events. Do we need resistive touch for the logo? |
The Python program below also doesn't work after changing to resistive mode, and the logo is_touched() state always seems less stable than MakeCode, I guess because microbit_hal_pin_is_touched uses uBit.logo.buttonActive(), which misses out on the isPressed() debounced state.
|
Thanks Martin, I can confirm that with the MicroPython example |
Quick summary:
|
Okay, a bit more detail:
This is correct right now, no action required.
uBit.io.logo default is resistive, and it should be capacitive:
This is also correct right now and no action is required.
This is the topic for this issue. Additionally |
So the main reason that the code in this issue doesn't work is because Three options to fix this issue:
|
Conclusion, we'll go for simplest fix:
|
Before we can complete this we need to ensure PR to set uBit.io.logo to capacitive by default: MicroPython already uses this method. Once the PR above is merged, we can submit this to MakeCode, I've tested this with pxt locally and works in resistive mode: Issue to track in MakeCode: |
Raised PR: We can close this ticket now. |
Does uBit.logo work only in capacitative mode or does the code below use the wrong method to switch modes?
After pressing button A to select TouchMode::Resistive, the logo is always pressed.
This example is intended to match the MakeCode code in microsoft/pxt-microbit#3724.
test-pintouch-v2.zip
The text was updated successfully, but these errors were encountered: