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

Create a generic ‘Pause Until’ block for micro-bit (like the block in Makecode for EV3) #5919

Open
mpoelzl opened this issue Sep 6, 2024 · 12 comments

Comments

@mpoelzl
Copy link

mpoelzl commented Sep 6, 2024

I am trying to create a ‘Pause Until’ block that can take a function with a boolean return value and pauses until it turn true. Makecode for the EV3 has such a block but not Makecode for micro:bit.

image

I can create the function but the corresponding block does not look as it should. Specifically it does not have the ‘pointy’ parameter placeholder where a boolean input can be placed.

As discussed here it is something that already exists and could be added: https://forum.makecode.com/t/create-a-generic-pause-until-block/30448

Would it be possible to make this block availble in Makecode for micro:bit?

Thank you!

@riknoll
Copy link
Member

riknoll commented Sep 12, 2024

I brought this up with the team, and opinions were torn on whether to add this to the toolbox; the main concern was that adding another block to the default toolbox might be overwhelming. We also discussed where to put it if we were to add it, with the main suggestions being the basic category (which is where the pause block is), loops (which is where it is in our other editors, somewhat arbitrarily), or control (which has the benefit of being in the "advanced" section and has similar blocks already)

Personally, I prefer control since it's out of the way and also is where we put the other pause/wait variants, including this one:

image

@microbit-carlos @jaustin @Jaqster would love to hear feedback on this

@mpoelzl
Copy link
Author

mpoelzl commented Sep 12, 2024

Thanks for the feedback! Personally I would argue for adding it to the basic category. I appreciate the concern with regards to "block overload" but I think especially for younger users this would greatly simplify sequence tasks which would otherwise need some form of 'pause loops'. With this in mind the basic category would be most helpful.

But in the end I would be grateful to have it, regardless of category!

@THEb0nny
Copy link

THEb0nny commented Sep 25, 2024

@riknoll the pause until block in ev3 is in cycles, which is logical, since it essentially defines a loop while that checks the event...

@microbit-carlos
Copy link
Collaborator

To make sure I understand this specific block:

  • The special thing about the [pause until < expression > ] block is that it needs to evaluate the boolean expression at a specific interval (per "frame" in arcade or "cycle" in ev3).
    • Would that be per tick in the micro:bit port?
  • Apart from the block wording being much more clear, would it offer other advantages compared to a loop like this?
    image

@riknoll
Copy link
Member

riknoll commented Oct 1, 2024

i believe it is functionally equivalent to the while loop example you provide. the only advantage is, as you said, better wording plus only needing one block vs three

@mpoelzl
Copy link
Author

mpoelzl commented Oct 1, 2024

Hello!
Yes, the while loop does provide the same functionality. The requests to add this new block is really to make the concept more accessible for the younger kids. We find that having to add the while loop and a 'not' logic is a big distraction when we really want to concentrate on the condition itself. Often we ask the kids to follow a series of instructions like:

  • Drive until the colour sensor detects green
  • Turn right
  • Drive until the sonar sensor detects a wall
  • Turn left
  • etc.

A 'Pause Until' block would make this kind of code really easy and clean.

Thanks!

@mpoelzl
Copy link
Author

mpoelzl commented Nov 17, 2024

Hello!
Are there any more thoughts on this? As mentioned above I think it would be a great addition for younger learners.

In any case, if the concern is that too many blocks are exposed i the standard toolbox then I would also be very happy to have it in the advance section.

@jaustin
Copy link
Collaborator

jaustin commented Nov 18, 2024

Hi @mpoelzl are you working with students inside a context where you are able to share code with them in advance? If so, you could make this a custom block inside the pre-shared example.

Another option would be to make this a small standalone extension

These have the upside of making the code available to you, but the downside that if you share example code that includes this block, students may later fail to find it when using Makecode without your example. If you publish an extension you can show them how to add it, but that is probably more complicated than just sharing the blocks.

OTOH, it's also a nice opportunity to introduce students to functions.

If you would like to express this as a custom block or in an extension, I'm happy to help you do that.

@mpoelzl
Copy link
Author

mpoelzl commented Nov 18, 2024

Hello!
Thanks for the reply. If you could help me to add this as a custom block in an extension that would be fantastic. I have already tried this but couldn't get the block to display correctly when I have a function returning a boolean value as a parameter. It did not display a "pointy" boolean input.

Just to add, this was already discussed here (and you can see the problem) and the feecback was that it is currently not possible to create this in an extension: https://forum.makecode.com/t/create-a-generic-pause-until-block/30448

@microbit-carlos
Copy link
Collaborator

@riknoll in order to test this from an extension, would enabling this feature in pxtarget.json have any impact into the MakeCode builds?

@riknoll
Copy link
Member

riknoll commented Nov 19, 2024

@microbit-carlos not sure what you mean by that. are you talking about code size? if so, that's not an issue. pauseUntil is already available today in TS we just hid the block for it.

@mpoelzl it's true that you can't create a block that takes a predicate like the pauseUntil block, but you can create a higher level block in an extension that calls pauseUntil. for example, if you had some sort of distance sensor:

namespace custom {
    //% block="pause until object detected $distance cm away"
    export function pauseUntilDistance(distance: number) {
        pauseUntil(() => sensor.distance() <= distance)
    }
}

@mpoelzl
Copy link
Author

mpoelzl commented Nov 20, 2024

@riknoll Thank you, but the aim really is to have a generic block that takes any predicate.

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

No branches or pull requests

6 participants