update input blocks in docs and tests

This commit is contained in:
Amerlander 2020-02-20 04:01:37 +01:00
parent 38cf0ec0c6
commit c2cdcaa40f
62 changed files with 109 additions and 115 deletions

View File

@ -22,13 +22,13 @@ Here's a program that simulates cell life in the LED matrix. Use button ``A`` fo
let lifeChart: Image = null let lifeChart: Image = null
//Use button A for the next iteration of game of life //Use button A for the next iteration of game of life
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
gameOfLife(); gameOfLife();
show(); show();
}) })
//Use button B for reseting to random initial seed state //Use button B for reseting to random initial seed state
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
reset(); reset();
show(); show();
}) })

View File

@ -11,7 +11,7 @@ Let's create a coin flipping program to simulate a real coin toss. We'll use ico
Get an ``||input:on button A pressed||`` block from the ``||input:Input||`` drawer in the toolbox. We'll put our coin flipping code in here. Get an ``||input:on button A pressed||`` block from the ``||input:Input||`` drawer in the toolbox. We'll put our coin flipping code in here.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
}) })
``` ```
@ -22,7 +22,7 @@ Grab an ``||logic:if else||`` block and set it inside ``||input:on button A pres
The ``||Math:pick random true or false||`` returns a random ``true`` or ``false`` value which we use to determine a ``heads`` or ``tails`` result for a coin toss. The ``||Math:pick random true or false||`` returns a random ``true`` or ``false`` value which we use to determine a ``heads`` or ``tails`` result for a coin toss.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (Math.randomBoolean()) { if (Math.randomBoolean()) {
} else { } else {
} }
@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => {
Now, put a ``||basic:show icon||`` block inside both the ``||logic:if||`` and the ``||logic:else||``. Pick images to mean ``heads`` and ``tails``. Now, put a ``||basic:show icon||`` block inside both the ``||logic:if||`` and the ``||logic:else||``. Pick images to mean ``heads`` and ``tails``.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (Math.randomBoolean()) { if (Math.randomBoolean()) {
basic.showIcon(IconNames.Skull) basic.showIcon(IconNames.Skull)
} else { } else {
@ -52,7 +52,7 @@ Press button **A** in the simulator to try the coin toss code.
You can animate the coin toss to add the feeling of suspense. Place different ``||basic:show icon||`` blocks before the ``||logic:if||`` to show that the coin is flipping. You can animate the coin toss to add the feeling of suspense. Place different ``||basic:show icon||`` blocks before the ``||logic:if||`` to show that the coin is flipping.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showIcon(IconNames.Diamond) basic.showIcon(IconNames.Diamond)
basic.showIcon(IconNames.SmallDiamond) basic.showIcon(IconNames.SmallDiamond)
basic.showIcon(IconNames.Diamond) basic.showIcon(IconNames.Diamond)

View File

@ -12,7 +12,7 @@ Tell everyone who you are. Show you name on the LEDs.
Let's build a **LOVE METER** machine. Place an ``||input:on pin pressed||`` block to run code when pin **0** is pressed. Use ``P0`` from the list of pin inputs. Let's build a **LOVE METER** machine. Place an ``||input:on pin pressed||`` block to run code when pin **0** is pressed. Use ``P0`` from the list of pin inputs.
```blocks ```blocks
input.onPinPressed(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, Button.Click, () => {
}); });
``` ```
@ -21,7 +21,7 @@ input.onPinPressed(TouchPin.P0, () => {
Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from `0` to `100` when pin **0** is pressed. Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from `0` to `100` when pin **0** is pressed.
```blocks ```blocks
input.onPinPressed(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, Button.Click, () => {
basic.showNumber(Math.randomRange(0, 100)); basic.showNumber(Math.randomRange(0, 100));
}); });
``` ```
@ -35,7 +35,7 @@ Show ``"LOVE METER"`` on the screen when the @boardname@ starts.
```blocks ```blocks
basic.showString("LOVE METER"); basic.showString("LOVE METER");
input.onPinPressed(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, Button.Click, () => {
basic.showNumber(Math.randomRange(0, 100)); basic.showNumber(Math.randomRange(0, 100));
}); });
``` ```

View File

@ -12,7 +12,7 @@ Use ``||input:on button pressed||`` to send a text message over radio with ``||r
Every @boardname@ nearby will receive this message. Every @boardname@ nearby will receive this message.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("Yo"); radio.sendString("Yo");
}); });
``` ```
@ -41,7 +41,7 @@ radio.onReceivedString(function (receivedString) {
Press button **A** on the simulator, you will notice that a second @boardname@ appears (if your screen is too small, the simulator might decide not to show it). Try pressing **A** again and notice that the "Yo" message gets displayed on the other @boardname@. Press button **A** on the simulator, you will notice that a second @boardname@ appears (if your screen is too small, the simulator might decide not to show it). Try pressing **A** again and notice that the "Yo" message gets displayed on the other @boardname@.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("Yo"); radio.sendString("Yo");
}); });
radio.onReceivedString(function (receivedString) { radio.onReceivedString(function (receivedString) {

View File

@ -12,7 +12,7 @@ Code the buttons on the @boardname@ to show that it's happy or sad.
Place a ``||input:on button pressed||`` block to run code when button **A** is pressed. Place a ``||input:on button pressed||`` block to run code when button **A** is pressed.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
}); });
``` ```
@ -21,7 +21,7 @@ input.onButtonPressed(Button.A, () => {
Place a ``||basic:show leds||`` block inside ``||input:on button pressed||`` to display a smiley on the screen. Press the **A** button in the simulator to see the smiley. Place a ``||basic:show leds||`` block inside ``||input:on button pressed||`` to display a smiley on the screen. Press the **A** button in the simulator to see the smiley.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showLeds(` basic.showLeds(`
# # . # # # # . # #
# # . # # # # . # #
@ -37,7 +37,7 @@ input.onButtonPressed(Button.A, () => {
Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed. Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showLeds(` basic.showLeds(`
# # . # # # # . # #
# # . # # # # . # #
@ -53,7 +53,7 @@ input.onButtonPressed(Button.B, () => {
Add a secret mode that happens when **A** and **B** are pressed together. For this case, add multiple ``||basic:show leds||`` blocks to create an animation. Add a secret mode that happens when **A** and **B** are pressed together. For this case, add multiple ``||basic:show leds||`` blocks to create an animation.
```blocks ```blocks
input.onButtonPressed(Button.AB, () => { input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showLeds(` basic.showLeds(`
. . . . . . . . . .
# . # . . # . # . .

View File

@ -55,7 +55,7 @@ Use a ``||input:on button pressed||`` block to handle the **A** button. Put in a
```blocks ```blocks
let sprite: game.LedSprite = null let sprite: game.LedSprite = null
input.onButtonPressed(Button.A, function () { input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
if (sprite.get(LedSpriteProperty.X) == 2) { if (sprite.get(LedSpriteProperty.X) == 2) {
} else { } else {
} }
@ -74,7 +74,7 @@ Finally, pull out an ``||game:add score||`` and a ``||game:game over||`` block t
```blocks ```blocks
let sprite: game.LedSprite = null let sprite: game.LedSprite = null
input.onButtonPressed(Button.A, function () { input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
if (sprite.get(LedSpriteProperty.X) == 2) { if (sprite.get(LedSpriteProperty.X) == 2) {
game.addScore(1) game.addScore(1)
} else { } else {

View File

@ -43,7 +43,7 @@ let num = 0
basic.forever(() => { basic.forever(() => {
basic.showNumber(num) basic.showNumber(num)
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
num = num + 1 num = num + 1
}) })
``` ```
@ -59,7 +59,7 @@ Try this on your @boardname@:
basic.forever(() => { basic.forever(() => {
basic.showNumber(6789) basic.showNumber(6789)
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showNumber(2) basic.showNumber(2)
}) })
``` ```

View File

@ -24,7 +24,7 @@ bluetooth.stopAdvertising();
## Example: stop advertising on button pressed ## Example: stop advertising on button pressed
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
bluetooth.stopAdvertising(); bluetooth.stopAdvertising();
}) })
``` ```

View File

@ -27,7 +27,7 @@ bluetooth.onBluetoothDisconnected(() => {
basic.showString("D"); basic.showString("D");
connected = 0; connected = 0;
}); });
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (connected == 1) { if (connected == 1) {
bluetooth.uartWriteLine("HELLO"); bluetooth.uartWriteLine("HELLO");
} }

View File

@ -27,7 +27,7 @@ bluetooth.onBluetoothDisconnected(() => {
basic.showString("D"); basic.showString("D");
connected = 0; connected = 0;
}); });
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (connected == 1) { if (connected == 1) {
bluetooth.uartWriteString("HELLO"); bluetooth.uartWriteString("HELLO");
} }

View File

@ -29,7 +29,7 @@ control.inBackground(() => {
basic.pause(100) basic.pause(100)
} }
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
num++; num++;
}) })
``` ```
@ -42,7 +42,7 @@ let num = 0
basic.forever(() => { basic.forever(() => {
basic.showNumber(num) basic.showNumber(num)
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
num++; num++;
}) })
``` ```

View File

@ -24,11 +24,11 @@ When you get tired of counting, press button `B` to reset the
```blocks ```blocks
let item = 0; let item = 0;
basic.showNumber(item); basic.showNumber(item);
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
item = item + 1; item = item + 1;
basic.showNumber(item); basic.showNumber(item);
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
control.reset(); control.reset();
}); });
``` ```

View File

@ -9,7 +9,7 @@ An event handler is code that is associated with a particular event, such as "bu
Functions named "on <event>" create an association between an event and the event handler code. For example, the following code registers the event handler (the code between the `do` and `end` keywords) with the event of a press of button A: Functions named "on <event>" create an association between an event and the event handler code. For example, the following code registers the event handler (the code between the `do` and `end` keywords) with the event of a press of button A:
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showString("hello", 150) basic.showString("hello", 150)
}) })
``` ```
@ -21,7 +21,7 @@ After this code executes, then whenever button A is pressed in the future, the s
Once you have registered an event handler for an event, like above, that event handler is active for the rest of the program execution. If you want to stop the string "hello" from printing each time button A is pressed then you need to arrange for the following code to execute: Once you have registered an event handler for an event, like above, that event handler is active for the rest of the program execution. If you want to stop the string "hello" from printing each time button A is pressed then you need to arrange for the following code to execute:
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
}) })
``` ```
@ -32,10 +32,10 @@ The above code associated an event handler that does nothing with the event of a
The above example also illustrates that there is only one event handler for each event. What is the result of the following code? The above example also illustrates that there is only one event handler for each event. What is the result of the following code?
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showString("hello", 150) basic.showString("hello", 150)
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showString("goodbye", 150) basic.showString("goodbye", 150)
}) })
``` ```
@ -43,7 +43,7 @@ input.onButtonPressed(Button.A, () => {
The answer is that whenever button A is pressed, the string "goodbye" will be printed. If you want both the strings "hello" and "goodbye" to be printed, you need to write the code like this: The answer is that whenever button A is pressed, the string "goodbye" will be printed. If you want both the strings "hello" and "goodbye" to be printed, you need to write the code like this:
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showString("hello", 150) basic.showString("hello", 150)
basic.showString("goodbye", 150) basic.showString("goodbye", 150)
}) })

View File

@ -16,11 +16,11 @@ Press button ``A`` as much as possible to increase the score.
Press ``B`` to display the score and reset the score. Press ``B`` to display the score and reset the score.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showNumber(game.score()) basic.showNumber(game.score())
game.setScore(0) game.setScore(0)
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
game.addScore(1) game.addScore(1)
}) })
``` ```

View File

@ -16,7 +16,7 @@ Press button ``A`` as much as possible.
At the end of 10 seconds, the program will show your score. At the end of 10 seconds, the program will show your score.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
game.addScore(1) game.addScore(1)
}) })
game.startCountdown(10000) game.startCountdown(10000)

View File

@ -27,7 +27,7 @@ let img = images.createImage(`
. . . . . . . . . .
`) `)
img.showImage(0) img.showImage(0)
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
img.clear() img.clear()
img.showImage(0) img.showImage(0)
}) })

View File

@ -14,10 +14,10 @@ If you press button `B`, it shows an animation and ends the game.
```blocks ```blocks
basic.showString("PICK A BUTTON"); basic.showString("PICK A BUTTON");
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showString("YOU WIN!"); basic.showString("YOU WIN!");
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
game.gameOver(); game.gameOver();
}); });
``` ```

View File

@ -20,7 +20,7 @@ degrees -- exactly the opposite direction.
```blocks ```blocks
let ball = game.createSprite(4, 2); let ball = game.createSprite(4, 2);
basic.showNumber(ball.get(LedSpriteProperty.Direction)); basic.showNumber(ball.get(LedSpriteProperty.Direction));
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
ball.ifOnEdgeBounce(); ball.ifOnEdgeBounce();
basic.showNumber(ball.get(LedSpriteProperty.Direction)); basic.showNumber(ball.get(LedSpriteProperty.Direction));
}); });

View File

@ -15,7 +15,7 @@ game.isPaused()
Resume the game if it's paused and button **B** is pressed. Resume the game if it's paused and button **B** is pressed.
```blocks ```blocks
input.onButtonPressed(Button.B, function () { input.input.onButtonEvent(Button.B, ButtonEvent.Click, function () {
if (game.isPaused()) { if (game.isPaused()) {
game.resume() game.resume()
} }

View File

@ -15,7 +15,7 @@ game.isRunning()
If the game is currently running, end the game if button **B** is pressed. If the game is currently running, end the game if button **B** is pressed.
```blocks ```blocks
input.onButtonPressed(Button.B, function () { input.input.onButtonEvent(Button.B, ButtonEvent.Click, function () {
if (game.isRunning()) { if (game.isRunning()) {
game.gameOver() game.gameOver()
} }

View File

@ -13,7 +13,7 @@ This program adds one point to your score every time you press button
second) and shows your score. second) and shows your score.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
game.addScore(1); game.addScore(1);
basic.pause(500); basic.pause(500);
basic.showNumber(game.score()); basic.showNumber(game.score());

View File

@ -16,11 +16,11 @@ Press button ``A`` as much as possible to increase the score.
Press ``B`` to display the score and reset the score. Press ``B`` to display the score and reset the score.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
basic.showNumber(game.score()) basic.showNumber(game.score())
game.setScore(0) game.setScore(0)
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
game.addScore(1) game.addScore(1)
}) })
``` ```

View File

@ -17,7 +17,7 @@ Press button ``A`` as much as possible.
At the end of 10 seconds, the program will show your score. At the end of 10 seconds, the program will show your score.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
game.addScore(1) game.addScore(1)
}) })
game.startCountdown(10000) game.startCountdown(10000)

View File

@ -29,10 +29,10 @@ Display a left arrow when button A is pressed or a right arrow when button B is
let arrowLeft = images.arrowImage(ArrowNames.West) let arrowLeft = images.arrowImage(ArrowNames.West)
let arrowRight = images.arrowImage(ArrowNames.East) let arrowRight = images.arrowImage(ArrowNames.East)
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
arrowLeft.showImage(0); arrowLeft.showImage(0);
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
arrowRight.showImage(0); arrowRight.showImage(0);
}); });
``` ```

View File

@ -36,10 +36,10 @@ let arrows = images.createBigImage(`
. . # . . . # # # . . . # . . . # # # .
. . # . . . . # . . . . # . . . . # . .
`); `);
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
arrows.showImage(0); arrows.showImage(0);
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
arrows.showImage(5); arrows.showImage(5);
}); });
``` ```

View File

@ -25,7 +25,7 @@ arrow and show it on the LED screen. If you press button `B`, the
program will show a picture of the arrow upside-down. program will show a picture of the arrow upside-down.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
images.createImage(` images.createImage(`
. . # . . . . # . .
. # # # . . # # # .
@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => {
. . # . . . . # . .
`).showImage(0); `).showImage(0);
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
images.createImage(` images.createImage(`
. . # . . . . # . .
. . # . . . . # . .

View File

@ -20,10 +20,10 @@ Show a happy face when button A is pressed or a sad face when button B is presse
let iamHappy = images.iconImage(IconNames.Happy) let iamHappy = images.iconImage(IconNames.Happy)
let iamSad = images.iconImage(IconNames.Sad) let iamSad = images.iconImage(IconNames.Sad)
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
iamHappy.showImage(0); iamHappy.showImage(0);
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
iamSad.showImage(0); iamSad.showImage(0);
}); });
``` ```

View File

@ -31,10 +31,10 @@ let arrows = images.createBigImage(`
. . # . . . # # # . . . # . . . # # # .
. . # . . . . # . . . . # . . . . # . .
`); `);
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
arrows.showImage(0); arrows.showImage(0);
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
arrows.showImage(5); arrows.showImage(5);
}); });
``` ```

View File

@ -3,13 +3,13 @@
Events and data from sensors Events and data from sensors
```cards ```cards
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
}); });
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
}); });
input.onPinPressed(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, Button.Click, () => {
}); });
input.buttonIsPressed(Button.A); input.buttonIsPressed(Button.A);

View File

@ -23,7 +23,7 @@ confuse the @boardname@.
This example runs the calibration when the user presses **A+B** buttons. This example runs the calibration when the user presses **A+B** buttons.
```blocks ```blocks
input.onButtonPressed(Button.AB, () => { input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.calibrateCompass(); input.calibrateCompass();
}) })
``` ```

View File

@ -70,7 +70,7 @@ confuse the @boardname@.
Keep the calibration handy by running it when the user pressed **A+B**. Keep the calibration handy by running it when the user pressed **A+B**.
```block ```block
input.onButtonPressed(Button.AB, () => { input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.calibrateCompass(); input.calibrateCompass();
}) })
``` ```

View File

@ -29,7 +29,7 @@ program shows the light level
on the [LED screen](/device/screen). on the [LED screen](/device/screen).
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
let level = input.lightLevel() let level = input.lightLevel()
basic.showNumber(level) basic.showNumber(level)
}) })

View File

@ -9,7 +9,7 @@ on the @boardname@.
* For `A` and `B` together: This handler works when `A` and `B` are both pushed down, then one of them is released within 1.5 seconds of pushing down the second button. * For `A` and `B` together: This handler works when `A` and `B` are both pushed down, then one of them is released within 1.5 seconds of pushing down the second button.
```sig ```sig
input.onButtonPressed(Button.A, () => {}) input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {})
``` ```
Find out how buttons provide input to the @boardname@ in this video: Find out how buttons provide input to the @boardname@ in this video:
@ -24,7 +24,7 @@ Each time you press the button, the [LED screen](/device/screen) shows the `coun
```blocks ```blocks
let count = 0 let count = 0
basic.showNumber(count) basic.showNumber(count)
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
count++; count++;
basic.showNumber(count); basic.showNumber(count);
}) })
@ -35,7 +35,7 @@ input.onButtonPressed(Button.A, () => {
This example shows a number from 1 to 6 when you press the `B` button. This example shows a number from 1 to 6 when you press the `B` button.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
let dice = Math.randomRange(0, 5) + 1 let dice = Math.randomRange(0, 5) + 1
basic.showNumber(dice) basic.showNumber(dice)
}) })

View File

@ -14,7 +14,7 @@ through your body and back into the @boardname@. This is called
**completing a circuit**. It's like you're a big wire! **completing a circuit**. It's like you're a big wire!
```sig ```sig
input.onPinPressed(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, Button.Click, () => {
}) })
``` ```
@ -43,7 +43,7 @@ Every time you press the pin, the program shows the number of times on the scree
```blocks ```blocks
let count = 0 let count = 0
basic.showNumber(count) basic.showNumber(count)
input.onPinPressed(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, Button.Click, () => {
count = count + 1 count = count + 1
basic.showNumber(count) basic.showNumber(count)
}) })

View File

@ -13,7 +13,7 @@ through your body and back into the @boardname@. This is called
**completing a circuit**. It's like you're a big wire! **completing a circuit**. It's like you're a big wire!
```sig ```sig
input.onPinReleased(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, ButtonEvent.Click, () => {
}) })
``` ```
@ -36,7 +36,7 @@ Every time you release the pin, the program shows the number of times on the scr
```blocks ```blocks
let count = 0 let count = 0
basic.showNumber(count, 100) basic.showNumber(count, 100)
input.onPinReleased(TouchPin.P0, () => { input.onPinEvent(TouchPin.P0, ButtonEvent.Click, () => {
count = count + 1 count = count + 1
basic.showNumber(count, 100) basic.showNumber(count, 100)
}) })

View File

@ -18,7 +18,7 @@ program finds the number of milliseconds since the program started
and shows it on the [LED screen](/device/screen). and shows it on the [LED screen](/device/screen).
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
let now = input.runningTime() let now = input.runningTime()
basic.showNumber(now) basic.showNumber(now)
}) })

View File

@ -15,7 +15,7 @@ led.enable(false);
This program turns off the screen when pressing button ``B`` This program turns off the screen when pressing button ``B``
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
led.enable(false) led.enable(false)
}); });
``` ```

View File

@ -13,7 +13,7 @@ This program sets up the ``stop animation`` part of the program,
and then shows a string that you can stop with button ``B``. and then shows a string that you can stop with button ``B``.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
led.stopAnimation(); led.stopAnimation();
}); });
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?"); basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");

View File

@ -43,7 +43,7 @@ music.onEvent(MusicEvent.BackgroundMelodyResumed, () => {
music.onEvent(MusicEvent.BackgroundMelodyRepeated, () => { music.onEvent(MusicEvent.BackgroundMelodyRepeated, () => {
serial.writeLine("background repeated") serial.writeLine("background repeated")
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
music.beginMelody(music.builtInMelody(Melodies.BaDing), MelodyOptions.Once) music.beginMelody(music.builtInMelody(Melodies.BaDing), MelodyOptions.Once)
}) })
music.setTempo(100) music.setTempo(100)

View File

@ -17,7 +17,7 @@ This example send the frequency and duration over radio
and plays it on the remote @boardname@. and plays it on the remote @boardname@.
```typescript ```typescript
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
music.playTone(440, 120) music.playTone(440, 120)
led.toggle(0, 0) led.toggle(0, 0)
}) })
@ -26,7 +26,7 @@ radio.onReceivedNumber(function (receivedNumber) {
const duration = receivedNumber & 0xffff; const duration = receivedNumber & 0xffff;
music.playTone(freq, duration); music.playTone(freq, duration);
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
music.setPlayTone((frequency: number, duration: number) => { music.setPlayTone((frequency: number, duration: number) => {
radio.sendNumber((frequency << 16) | (duration & 0xffff)); radio.sendNumber((frequency << 16) | (duration & 0xffff));
}) })

View File

@ -48,7 +48,7 @@ keeper @boardname@, you can press button `B` on the remote to buzz and
make the score bigger on the other @boardname@. make the score bigger on the other @boardname@.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
pins.digitalWritePin(DigitalPin.P1, 1); pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500); basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0); pins.digitalWritePin(DigitalPin.P1, 0);

View File

@ -46,7 +46,7 @@ will use ``digital write pin`` to make the other @boardname@ buzz and
make the score bigger. make the score bigger.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
pins.digitalWritePin(DigitalPin.P1, 1); pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500); basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0); pins.digitalWritePin(DigitalPin.P1, 0);

View File

@ -34,7 +34,7 @@ If you load this program onto two or more @boardname@s, you can send a code word
The other @boardname@s will receive the code word and then show it. The other @boardname@s will receive the code word and then show it.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("Codeword: TRIMARAN") radio.sendString("Codeword: TRIMARAN")
basic.showString("SENT"); basic.showString("SENT");
}) })
@ -59,10 +59,10 @@ This program will also receive your friend's mood.
```blocks ```blocks
let data: string = ""; let data: string = "";
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("H"); radio.sendString("H");
}); });
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("S"); radio.sendString("S");
}); });
radio.onDataReceived(() => { radio.onDataReceived(() => {

View File

@ -27,7 +27,7 @@ in the `x` direction (left and right) to other @boardname@s. This kind
of program might be useful in a model car or model rocket. of program might be useful in a model car or model rocket.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendNumber(input.acceleration(Dimension.X)) radio.sendNumber(input.acceleration(Dimension.X))
}) })
``` ```

View File

@ -26,7 +26,7 @@ code word from one of them to the others by pressing button `A`. The
other @boardname@s will receive the code word and then show it. other @boardname@s will receive the code word and then show it.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendString("Codeword: TRIMARAN") radio.sendString("Codeword: TRIMARAN")
basic.showString("SENT"); basic.showString("SENT");
}) })

View File

@ -29,7 +29,7 @@ or model rocket.
```blocks ```blocks
radio.setGroup(99) radio.setGroup(99)
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendValue("acc", input.acceleration(Dimension.X)) radio.sendValue("acc", input.acceleration(Dimension.X))
}) })
``` ```

View File

@ -30,7 +30,7 @@ the second @boardname@), this program sends temperature data to the
serial port. serial port.
```blocks ```blocks
input.onButtonPressed(Button.A, function () { input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
radio.sendNumber(input.temperature()) radio.sendNumber(input.temperature())
radio.sendValue("temp", input.temperature()) radio.sendValue("temp", input.temperature())
radio.sendString("It's warm now") radio.sendString("It's warm now")

View File

@ -29,7 +29,7 @@ the second @boardname@), this program sends temperature data to
serial. serial.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
radio.sendNumber(input.temperature()); radio.sendNumber(input.temperature());
}); });
radio.onDataReceived(() => { radio.onDataReceived(() => {

View File

@ -32,7 +32,7 @@ serial port to use the pins. The new configuration uses pin ``P1`` to transmit a
``P2`` to receive. The baud rate is set to `9600`. ``P2`` to receive. The baud rate is set to `9600`.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600); serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600);
}); });
``` ```

View File

@ -57,7 +57,7 @@ You could simply save the light measurements in an array like this:
```blocks ```blocks
let darkness: number[] = [] let darkness: number[] = []
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
for (let i = 0; i < 60 * 4; i++) { for (let i = 0; i < 60 * 4; i++) {
darkness.push(input.lightLevel()) darkness.push(input.lightLevel())
basic.pause(60000) basic.pause(60000)
@ -77,7 +77,7 @@ The code in blocks for recording the light level is modified to make our file da
```typescript-ignore ```typescript-ignore
let darkness = pins.createBuffer(60 * 4); let darkness = pins.createBuffer(60 * 4);
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
for (let i = 0; i < 60 * 4; i++) { for (let i = 0; i < 60 * 4; i++) {
darkness.setNumber(NumberFormat.UInt8LE, i, input.lightLevel()) darkness.setNumber(NumberFormat.UInt8LE, i, input.lightLevel())
basic.pause(60000) basic.pause(60000)
@ -90,7 +90,7 @@ Later, we can upload the file to the laptop computer by pressing the **B** butto
```typescript-ignore ```typescript-ignore
let dataReady = false; let dataReady = false;
let darkness = pins.createBuffer(60 * 4); let darkness = pins.createBuffer(60 * 4);
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
for (let i = 0; i < 60 * 4; i++) { for (let i = 0; i < 60 * 4; i++) {
darkness.setNumber(NumberFormat.UInt8LE, i, input.lightLevel()) darkness.setNumber(NumberFormat.UInt8LE, i, input.lightLevel())
basic.pause(60000) basic.pause(60000)
@ -98,7 +98,7 @@ input.onButtonPressed(Button.A, () => {
dataReady = true; dataReady = true;
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (dataReady) { if (dataReady) {
serial.writeLine("Transferring file: DARKNESS, Length: " + darkness.length + " bytes..."); serial.writeLine("Transferring file: DARKNESS, Length: " + darkness.length + " bytes...");
serial.writeBuffer(darkness) serial.writeBuffer(darkness)

View File

@ -126,7 +126,4 @@
<block type="device_pin_event" x="555" y="96"> <block type="device_pin_event" x="555" y="96">
<field name="name">TouchPin.P2</field> <field name="name">TouchPin.P2</field>
</block> </block>
<block type="device_pin_released" x="188" y="435">
<field name="NAME">TouchPin.P2</field>
</block>
</xml> </xml>

View File

@ -350,9 +350,6 @@
<shadow type="math_number" id="RP?w4vFS1wB4I0nNyldb"> <shadow type="math_number" id="RP?w4vFS1wB4I0nNyldb">
<field name="NUM">0</field> <field name="NUM">0</field>
</shadow> </shadow>
<block type="device_pin_is_pressed">
<field name="NAME">TouchPin.P2</field>
</block>
</value> </value>
<next> <next>
<block type="variables_set"> <block type="variables_set">

View File

@ -22,10 +22,10 @@ enum RadioMessage {
heart, heart,
skull skull
} }
input.onButtonPressed(Button.A, function () { input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
radio.sendMessage(RadioMessage.heart) radio.sendMessage(RadioMessage.heart)
}) })
input.onButtonPressed(Button.B, function () { input.input.onButtonEvent(Button.B, ButtonEvent.Click, function () {
radio.sendMessage(RadioMessage.skull) radio.sendMessage(RadioMessage.skull)
}) })
radio.onReceivedMessage(RadioMessage.heart, function () { radio.onReceivedMessage(RadioMessage.heart, function () {

View File

@ -20,10 +20,10 @@ enum RadioMessage {
heart, heart,
skull skull
} }
input.onButtonPressed(Button.A, function () { input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
radio.sendMessage(RadioMessage.heart) radio.sendMessage(RadioMessage.heart)
}) })
input.onButtonPressed(Button.B, function () { input.input.onButtonEvent(Button.B, ButtonEvent.Click, function () {
radio.sendMessage(RadioMessage.skull) radio.sendMessage(RadioMessage.skull)
}) })
radio.onReceivedMessage(RadioMessage.heart, function () { radio.onReceivedMessage(RadioMessage.heart, function () {

View File

@ -332,12 +332,12 @@ function checkBufferEqual(a: Buffer, b: Buffer) {
return true; return true;
} }
input.onButtonPressed(Button.A, function () { input.input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
basic.showString("S"); basic.showString("S");
initSender(); initSender();
}) })
input.onButtonPressed(Button.B, function () { input.input.onButtonEvent(Button.B, ButtonEvent.Click, function () {
basic.showString("R"); basic.showString("R");
initReceiver(); initReceiver();
}) })

View File

@ -7,7 +7,7 @@ let level: number
let swapSpeed: number let swapSpeed: number
initializeGame() initializeGame()
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (ballRevealing) { if (ballRevealing) {
index = index + 1 index = index + 1
if (index > 2) { if (index > 2) {
@ -16,7 +16,7 @@ input.onButtonPressed(Button.A, () => {
basic.showString(cupSelect[index], 150) basic.showString(cupSelect[index], 150)
} }
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (ballRevealing) { if (ballRevealing) {
ballRevealing = false ballRevealing = false
if (correctBall == index) { if (correctBall == index) {

View File

@ -18,7 +18,7 @@ counter = 0
pause = 700 pause = 700
led.plot(oneX, oneY) led.plot(oneX, oneY)
led.plot(twoX, twoY) led.plot(twoX, twoY)
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (oneX > 0) { if (oneX > 0) {
led.unplot(oneX, oneY) led.unplot(oneX, oneY)
led.unplot(twoX, twoY) led.unplot(twoX, twoY)
@ -28,7 +28,7 @@ input.onButtonPressed(Button.A, () => {
led.plot(twoX, twoY) led.plot(twoX, twoY)
} }
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
if (twoX < 4) { if (twoX < 4) {
led.unplot(oneX, oneY) led.unplot(oneX, oneY)
led.unplot(twoX, twoY) led.unplot(twoX, twoY)

View File

@ -107,12 +107,12 @@ basic.forever(() => {
basic.pause(500) basic.pause(500)
} }
}) })
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
let temp = Math.abs(person.dirX) * (-1) let temp = Math.abs(person.dirX) * (-1)
person.dirX = Math.abs(person.dirY) * (-1) person.dirX = Math.abs(person.dirY) * (-1)
person.dirY = temp person.dirY = temp
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
let temp1 = Math.abs(person.dirX) let temp1 = Math.abs(person.dirX)
person.dirX = Math.abs(person.dirY) person.dirX = Math.abs(person.dirY)
person.dirY = temp1 person.dirY = temp1

View File

@ -24,13 +24,13 @@ playOneGame(gameTime)
showFinalScores(scoreA, scoreB) showFinalScores(scoreA, scoreB)
function startIOMonitor() { function startIOMonitor() {
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
AWasPressed = true AWasPressed = true
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
BWasPressed = true BWasPressed = true
}) })
input.onButtonPressed(Button.AB, () => { input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
ABWasPressed = true ABWasPressed = true
AWasPressed = false AWasPressed = false
BWasPressed = false BWasPressed = false

View File

@ -501,13 +501,13 @@ function convertPenaltyTimeToScore(penaltyTime: number): number {
} }
function startIOMonitor() { function startIOMonitor() {
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
AWasPressed = true AWasPressed = true
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
BWasPressed = true BWasPressed = true
}) })
input.onButtonPressed(Button.AB, () => { input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
ABWasPressed = true ABWasPressed = true
}) })
input.onShake(() => { input.onShake(() => {

View File

@ -377,11 +377,11 @@ function beepNTimesFor(times: number, duration: number) {
function startIOMonitor() { function startIOMonitor() {
aWasPressed = false aWasPressed = false
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
aWasPressed = true aWasPressed = true
}) })
bWasPressed = false bWasPressed = false
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
bWasPressed = true bWasPressed = true
}) })
wasTweezers = false wasTweezers = false

View File

@ -476,10 +476,10 @@ function testTiltZ() {
} }
function startIOMonitor() { function startIOMonitor() {
input.onButtonPressed(Button.A, () => { input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
AWasPressed = true AWasPressed = true
}) })
input.onButtonPressed(Button.B, () => { input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
BWasPressed = true BWasPressed = true
}) })
input.onShake(() => { input.onShake(() => {