Skip to content

lack of was_touched for pin_logo makes it less useful as a 'third button' #149

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

Closed
jaustin opened this issue Dec 29, 2022 · 12 comments
Closed
Labels
Milestone

Comments

@jaustin
Copy link
Contributor

jaustin commented Dec 29, 2022

For the buttons we can easily write code that's not super time-dependent wrt things happening in the main loop, by using was_pressed. However, with the pin_logo, as far as I can see can only test whether it is_touched.

I wouldn't be against having a was_pressed for all touch pins, either. Does anyone recall the reason for not having was_ methods for pins?

@microbit-carlos
Copy link
Contributor

I don't recall there being a specific reason why pin_logo.was_pressed() was not added, I think it was mostly a matter of not being specified.

The rational at the time was to implement pin_logo similarly to the pin0/1/2, as a MicroBitTouchPin instance, as that is really what it is. The only class with a was_pressed() method is the MicroBitButton, so it is not present in the large pins either:

So if we'd like to implement this it would have to be by adding a was_touched method to MicroBitTouchPin, which would apply to pin 0/1/2 as well.

@jaustin
Copy link
Contributor Author

jaustin commented Jan 4, 2023

I'm fully supportive of adding was_touched to all pins, including the logo, unless it presents significant size or performance issues on V1/V2.

@dpgeorge
Copy link
Collaborator

For V1 this should be straightforward, because all the code is already there to debounce touch and compute the "was touched" state. It just has to be wired up for P0/P1/P2.

For V2 it depends on the CODAL. The logo should work fine because uBit.logo is a TouchButton instance with a wasPressed() method. For P0/P1/P2 it's not clear that it'll work because I don't see any instance of a Button/TouchButton for these pins.

@microbit-carlos
Copy link
Contributor

@microbit-carlos microbit-carlos added this to the 2.2 milestone Jan 19, 2023
@dpgeorge
Copy link
Collaborator

I assume we also want to implement get_touches() which will return the number of touches since the last time it was called.

@microbit-carlos
Copy link
Contributor

microbit-carlos commented Feb 13, 2023

Yes, for symmetry we should add get_touches().
Is MicroBitButton.get_presses() method implemented in MicroPython? So I assume adding it to the touch button doesn't require an additional CODAL method other than wasTouched()?


Edit: Just saw the comment in lancaster-university/codal-microbit-v2#251 (comment) 👍

@dpgeorge
Copy link
Collaborator

dpgeorge commented Mar 13, 2023

was_touched() and get_touches() have now been implemented on v1.

@dpgeorge
Copy link
Collaborator

CODAL as at v0.2.63 has added the wasTouched() method.

@dpgeorge dpgeorge removed the blocked label Nov 13, 2023
dpgeorge added a commit that referenced this issue Nov 13, 2023
Pins with these new methods are: pin0, pin1, pin2, pin_logo.

Fixes issue #149.

Signed-off-by: Damien George <[email protected]>
@dpgeorge
Copy link
Collaborator

was_touched() and get_touches() have been implemented on pin0, pin1, pin2 and pin_logo in 957e810

For pin_logo the code now uses uBit.io.logo.isTouched() rather than uBit.logo.buttonActive() to implement the Python-level pin_logo.is_touched() method. I'm not sure if this makes a difference? From my testing the new version seems less sensitive.

@microbit-carlos
Copy link
Contributor

microbit-carlos commented Mar 6, 2024

The only thing left to close this task is implementing this in CODAL and revert 3074c81:

@microbit-carlos
Copy link
Contributor

The only thing left to close this task is implementing this in CODAL and revert 3074c81:

Done in #213.

@kevinjwalters
Copy link

Is there user feedback on this? I wanted to implement a touch and measure how long the logo was pressed for and did this with pin_logo.is_touched(). Unless presses were very quick with finger cleanly withdrawn I got a lot multiple presses.

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

4 participants