microsoft / pxt-ev3

Microsoft MakeCode editor for the LEGO MINDSTORMS EV3 Brick
https://makecode.mindstorms.com/
Other
55 stars 39 forks source link

Safepolling #915

Closed pelikhan closed 5 years ago

pelikhan commented 5 years ago

Preparing for GC support: no more unsafe polling and support for tight loops.

With this changes, the following tight loop works:

console.sendToScreen()
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
    console.log("pressed")
})
console.log("start forever")
motors.largeBC.run(50)
while (!sensors.touch1.isPressed()) {
}
console.log("run")
motors.stopAll()
console.log("stopped")