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

Pins pressed/released confusion #2495

Closed
HelenFoster opened this issue Jul 21, 2017 · 5 comments
Closed

Pins pressed/released confusion #2495

HelenFoster opened this issue Jul 21, 2017 · 5 comments

Comments

@HelenFoster
Copy link

There are two blocks for pin-touch-related events: onPinPressed is CLICK and onPinReleased is UP.

As there are two blocks, and "pressed" and "released" can be opposites in natural language, there's a strong implication that these blocks have opposite actions. In reality, they do almost the same thing.

Adding the DOWN block would help with this, but naming it is a problem (as the other two have painted it into a corner).

The sprite here normally doesn't go anywhere, but we can make it move to the right with a long click:

let item: game.LedSprite = null
input.onPinPressed(TouchPin.P0, () => {
    item.change(LedSpriteProperty.X, -1)
})
input.onPinReleased(TouchPin.P0, () => {
    item.change(LedSpriteProperty.X, 1)
})
item = game.createSprite(2, 2)
@HelenFoster
Copy link
Author

HelenFoster commented Jul 21, 2017

In the spirit of a minimal number of blocks: rather than add a block, maybe deprecate onPinReleased and implement #2463 to replace the removed functionality.

Something like this but with UP instead of CLICK:

(This code is a bit nasty, but only people with special requirements will care about the difference between UP and CLICK.)

button_pressed

let tmp = false
let item: game.LedSprite = null
control.onEvent(EventBusSource.MICROBIT_ID_IO_P0, EventBusValue.MICROBIT_BUTTON_EVT_CLICK, () => {
    item.change(LedSpriteProperty.X, 1)
})
item = game.createSprite(0, 2)
tmp = input.pinIsPressed(TouchPin.P0)

@riknoll
Copy link
Member

riknoll commented Jul 22, 2017

Yep, that is very confusing. We don't remove blocks very often though. Maybe we should hide onPinReleased from the toolbox but still allow it in the editor so that we don't break any scripts.

@pelikhan
Copy link
Member

pelikhan commented Jul 22, 2017 via email

@HelenFoster
Copy link
Author

Looks like onPinReleased is already in advanced. That makes it go onto the second page of Input blocks after the "more", right? (As a user, I didn't notice there was a difference between the two pages.)

If adding the other one, onPinTouched might be an OK name for it.

@lock
Copy link

lock bot commented Sep 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants