From 07fe2645cf07f42d8242877163ad4c1f99e00768 Mon Sep 17 00:00:00 2001 From: Amerlander Date: Thu, 20 Feb 2020 17:00:11 +0100 Subject: [PATCH] Hide DAL.x behind Enum --- docs/examples/gameofLife.md | 4 ++-- docs/projects/coin-flipper.md | 8 ++++---- docs/projects/mini-chat.md | 4 ++-- docs/projects/smiley-buttons.md | 8 ++++---- docs/reference/basic/forever.md | 4 ++-- docs/reference/bluetooth/stop-advertising.md | 2 +- docs/reference/bluetooth/uart-write-line.md | 2 +- docs/reference/bluetooth/uart-write-string.md | 2 +- docs/reference/control/in-background.md | 4 ++-- docs/reference/control/reset.md | 4 ++-- docs/reference/event-handler.md | 10 +++++----- docs/reference/game/add-score.md | 4 ++-- docs/reference/game/change-score-by.md | 2 +- docs/reference/game/clear.md | 2 +- docs/reference/game/game-over.md | 4 ++-- docs/reference/game/if-on-edge-bounce.md | 2 +- docs/reference/game/score.md | 2 +- docs/reference/game/set-score.md | 4 ++-- docs/reference/game/start-countdown.md | 2 +- docs/reference/images/arrow-image.md | 4 ++-- docs/reference/images/create-big-image.md | 4 ++-- docs/reference/images/create-image.md | 4 ++-- docs/reference/images/icon-image.md | 4 ++-- docs/reference/images/show-image.md | 4 ++-- docs/reference/input.md | 2 +- docs/reference/input/calibrate-compass.md | 2 +- docs/reference/input/compass-heading.md | 2 +- docs/reference/input/light-level.md | 2 +- docs/reference/input/on-button-pressed.md | 6 +++--- docs/reference/input/running-time.md | 2 +- docs/reference/led/enable.md | 2 +- docs/reference/led/stop-animation.md | 2 +- docs/reference/music/on-event.md | 2 +- docs/reference/music/set-play-tone.md | 4 ++-- docs/reference/pins/digital-read-pin.md | 2 +- docs/reference/pins/digital-write-pin.md | 2 +- docs/reference/radio/receive-string.md | 6 +++--- docs/reference/radio/send-number.md | 2 +- docs/reference/radio/send-string.md | 2 +- docs/reference/radio/send-value.md | 2 +- docs/reference/radio/write-value-to-serial.md | 2 +- docs/reference/serial/redirect.md | 2 +- docs/types/buffer/using-buffers.md | 8 ++++---- libs/core/_locales/core-jsdoc-strings.json | 2 +- libs/core/game.ts | 6 +++--- libs/core/input.cpp | 4 ++-- libs/core/shims.d.ts | 4 ++-- sim/state/buttonpair.ts | 4 ++-- sim/state/edgeconnector.ts | 2 +- tests/hat-game.ts | 4 ++-- tests/meteorite.ts | 4 ++-- tests/pac-man-runaway.ts | 4 ++-- tests/wg-canoe-polo-timer.ts | 6 +++--- tests/wg-dr-who.ts | 6 +++--- tests/wg-operation.ts | 4 ++-- tests/wg-user-confidance.ts | 4 ++-- 56 files changed, 101 insertions(+), 101 deletions(-) diff --git a/docs/examples/gameofLife.md b/docs/examples/gameofLife.md index 216c05dc..78eb9a93 100644 --- a/docs/examples/gameofLife.md +++ b/docs/examples/gameofLife.md @@ -22,13 +22,13 @@ Here's a program that simulates cell life in the LED matrix. Use button ``A`` fo let lifeChart: Image = null //Use button A for the next iteration of game of life -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { gameOfLife(); show(); }) //Use button B for reseting to random initial seed state -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { reset(); show(); }) diff --git a/docs/projects/coin-flipper.md b/docs/projects/coin-flipper.md index 0e5e8baa..b65b36ff 100644 --- a/docs/projects/coin-flipper.md +++ b/docs/projects/coin-flipper.md @@ -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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (Math.randomBoolean()) { } else { } @@ -34,7 +34,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { Now, put a ``||basic:show icon||`` block inside both the ``||logic:if||`` and the ``||logic:else||``. Pick images to mean ``heads`` and ``tails``. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (Math.randomBoolean()) { basic.showIcon(IconNames.Skull) } 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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showIcon(IconNames.Diamond) basic.showIcon(IconNames.SmallDiamond) basic.showIcon(IconNames.Diamond) diff --git a/docs/projects/mini-chat.md b/docs/projects/mini-chat.md index 2d65dd8b..7cd388e8 100644 --- a/docs/projects/mini-chat.md +++ b/docs/projects/mini-chat.md @@ -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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 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@. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendString("Yo"); }); radio.onReceivedString(function (receivedString) { diff --git a/docs/projects/smiley-buttons.md b/docs/projects/smiley-buttons.md index d5984062..1ed6f803 100644 --- a/docs/projects/smiley-buttons.md +++ b/docs/projects/smiley-buttons.md @@ -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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { }); ``` @@ -21,7 +21,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { 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 -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showLeds(` # # . # # # # . # # @@ -37,7 +37,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed. ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { basic.showLeds(` # # . # # # # . # # @@ -53,7 +53,7 @@ input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { 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 -input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { basic.showLeds(` . . . . . # . # . . diff --git a/docs/reference/basic/forever.md b/docs/reference/basic/forever.md index 47eab400..7e73b163 100644 --- a/docs/reference/basic/forever.md +++ b/docs/reference/basic/forever.md @@ -43,7 +43,7 @@ let num = 0 basic.forever(() => { basic.showNumber(num) }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { num = num + 1 }) ``` @@ -59,7 +59,7 @@ Try this on your @boardname@: basic.forever(() => { basic.showNumber(6789) }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showNumber(2) }) ``` diff --git a/docs/reference/bluetooth/stop-advertising.md b/docs/reference/bluetooth/stop-advertising.md index 3958ccaa..cbd4e731 100644 --- a/docs/reference/bluetooth/stop-advertising.md +++ b/docs/reference/bluetooth/stop-advertising.md @@ -24,7 +24,7 @@ bluetooth.stopAdvertising(); ## Example: stop advertising on button pressed ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { bluetooth.stopAdvertising(); }) ``` diff --git a/docs/reference/bluetooth/uart-write-line.md b/docs/reference/bluetooth/uart-write-line.md index 2caa6eea..865fd264 100644 --- a/docs/reference/bluetooth/uart-write-line.md +++ b/docs/reference/bluetooth/uart-write-line.md @@ -27,7 +27,7 @@ bluetooth.onBluetoothDisconnected(() => { basic.showString("D"); connected = 0; }); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (connected == 1) { bluetooth.uartWriteLine("HELLO"); } diff --git a/docs/reference/bluetooth/uart-write-string.md b/docs/reference/bluetooth/uart-write-string.md index 8bad7cf0..f36655a6 100644 --- a/docs/reference/bluetooth/uart-write-string.md +++ b/docs/reference/bluetooth/uart-write-string.md @@ -27,7 +27,7 @@ bluetooth.onBluetoothDisconnected(() => { basic.showString("D"); connected = 0; }); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (connected == 1) { bluetooth.uartWriteString("HELLO"); } diff --git a/docs/reference/control/in-background.md b/docs/reference/control/in-background.md index 0a697722..3801cd43 100644 --- a/docs/reference/control/in-background.md +++ b/docs/reference/control/in-background.md @@ -29,7 +29,7 @@ control.inBackground(() => { basic.pause(100) } }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { num++; }) ``` @@ -42,7 +42,7 @@ let num = 0 basic.forever(() => { basic.showNumber(num) }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { num++; }) ``` diff --git a/docs/reference/control/reset.md b/docs/reference/control/reset.md index 6551ee34..3fc9388f 100644 --- a/docs/reference/control/reset.md +++ b/docs/reference/control/reset.md @@ -24,11 +24,11 @@ When you get tired of counting, press button `B` to reset the ```blocks let item = 0; basic.showNumber(item); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { item = item + 1; basic.showNumber(item); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { control.reset(); }); ``` diff --git a/docs/reference/event-handler.md b/docs/reference/event-handler.md index 09016bc2..217c23e7 100644 --- a/docs/reference/event-handler.md +++ b/docs/reference/event-handler.md @@ -9,7 +9,7 @@ An event handler is code that is associated with a particular event, such as "bu Functions named "on " 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 -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 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: ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.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? ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("hello", 150) }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("goodbye", 150) }) ``` @@ -43,7 +43,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { 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 -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("hello", 150) basic.showString("goodbye", 150) }) diff --git a/docs/reference/game/add-score.md b/docs/reference/game/add-score.md index d7099edc..d38fdebc 100644 --- a/docs/reference/game/add-score.md +++ b/docs/reference/game/add-score.md @@ -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. ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { basic.showNumber(game.score()) game.setScore(0) }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { game.addScore(1) }) ``` diff --git a/docs/reference/game/change-score-by.md b/docs/reference/game/change-score-by.md index d960d94f..3756157c 100644 --- a/docs/reference/game/change-score-by.md +++ b/docs/reference/game/change-score-by.md @@ -16,7 +16,7 @@ Press button ``A`` as much as possible. At the end of 10 seconds, the program will show your score. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { game.addScore(1) }) game.startCountdown(10000) diff --git a/docs/reference/game/clear.md b/docs/reference/game/clear.md index 1ed23f73..9a8b6c75 100644 --- a/docs/reference/game/clear.md +++ b/docs/reference/game/clear.md @@ -27,7 +27,7 @@ let img = images.createImage(` . . . . . `) img.showImage(0) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { img.clear() img.showImage(0) }) diff --git a/docs/reference/game/game-over.md b/docs/reference/game/game-over.md index 38b2a4be..bd2e3e2e 100644 --- a/docs/reference/game/game-over.md +++ b/docs/reference/game/game-over.md @@ -14,10 +14,10 @@ If you press button `B`, it shows an animation and ends the game. ```blocks basic.showString("PICK A BUTTON"); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("YOU WIN!"); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { game.gameOver(); }); ``` diff --git a/docs/reference/game/if-on-edge-bounce.md b/docs/reference/game/if-on-edge-bounce.md index a412d4ec..dfad29b3 100644 --- a/docs/reference/game/if-on-edge-bounce.md +++ b/docs/reference/game/if-on-edge-bounce.md @@ -20,7 +20,7 @@ degrees -- exactly the opposite direction. ```blocks let ball = game.createSprite(4, 2); basic.showNumber(ball.get(LedSpriteProperty.Direction)); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { ball.ifOnEdgeBounce(); basic.showNumber(ball.get(LedSpriteProperty.Direction)); }); diff --git a/docs/reference/game/score.md b/docs/reference/game/score.md index 14400760..faab5c0d 100644 --- a/docs/reference/game/score.md +++ b/docs/reference/game/score.md @@ -13,7 +13,7 @@ This program adds one point to your score every time you press button second) and shows your score. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { game.addScore(1); basic.pause(500); basic.showNumber(game.score()); diff --git a/docs/reference/game/set-score.md b/docs/reference/game/set-score.md index 37ebcac2..acdb65b5 100644 --- a/docs/reference/game/set-score.md +++ b/docs/reference/game/set-score.md @@ -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. ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { basic.showNumber(game.score()) game.setScore(0) }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { game.addScore(1) }) ``` diff --git a/docs/reference/game/start-countdown.md b/docs/reference/game/start-countdown.md index 780e46b5..86a9be1c 100644 --- a/docs/reference/game/start-countdown.md +++ b/docs/reference/game/start-countdown.md @@ -17,7 +17,7 @@ Press button ``A`` as much as possible. At the end of 10 seconds, the program will show your score. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { game.addScore(1) }) game.startCountdown(10000) diff --git a/docs/reference/images/arrow-image.md b/docs/reference/images/arrow-image.md index 0479f00e..44d4d752 100644 --- a/docs/reference/images/arrow-image.md +++ b/docs/reference/images/arrow-image.md @@ -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 arrowRight = images.arrowImage(ArrowNames.East) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { arrowLeft.showImage(0); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { arrowRight.showImage(0); }); ``` diff --git a/docs/reference/images/create-big-image.md b/docs/reference/images/create-big-image.md index b7779de9..9f040579 100644 --- a/docs/reference/images/create-big-image.md +++ b/docs/reference/images/create-big-image.md @@ -36,10 +36,10 @@ let arrows = images.createBigImage(` . . # . . . # # # . . . # . . . . # . . `); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { arrows.showImage(0); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { arrows.showImage(5); }); ``` diff --git a/docs/reference/images/create-image.md b/docs/reference/images/create-image.md index 821bcab5..c89525a6 100644 --- a/docs/reference/images/create-image.md +++ b/docs/reference/images/create-image.md @@ -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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { images.createImage(` . . # . . . # # # . @@ -34,7 +34,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { . . # . . `).showImage(0); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { images.createImage(` . . # . . . . # . . diff --git a/docs/reference/images/icon-image.md b/docs/reference/images/icon-image.md index b138b1f7..28b71f62 100644 --- a/docs/reference/images/icon-image.md +++ b/docs/reference/images/icon-image.md @@ -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 iamSad = images.iconImage(IconNames.Sad) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { iamHappy.showImage(0); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { iamSad.showImage(0); }); ``` diff --git a/docs/reference/images/show-image.md b/docs/reference/images/show-image.md index 7b49156c..87b7559e 100644 --- a/docs/reference/images/show-image.md +++ b/docs/reference/images/show-image.md @@ -31,10 +31,10 @@ let arrows = images.createBigImage(` . . # . . . # # # . . . # . . . . # . . `); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { arrows.showImage(0); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { arrows.showImage(5); }); ``` diff --git a/docs/reference/input.md b/docs/reference/input.md index 2ffdb66a..c955bda0 100644 --- a/docs/reference/input.md +++ b/docs/reference/input.md @@ -3,7 +3,7 @@ Events and data from sensors ```cards -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { }); input.onGesture(Gesture.Shake, () => { diff --git a/docs/reference/input/calibrate-compass.md b/docs/reference/input/calibrate-compass.md index 2db27343..8d4f4d6a 100644 --- a/docs/reference/input/calibrate-compass.md +++ b/docs/reference/input/calibrate-compass.md @@ -23,7 +23,7 @@ confuse the @boardname@. This example runs the calibration when the user presses **A+B** buttons. ```blocks -input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { input.calibrateCompass(); }) ``` diff --git a/docs/reference/input/compass-heading.md b/docs/reference/input/compass-heading.md index 32f66612..cd6cfabd 100644 --- a/docs/reference/input/compass-heading.md +++ b/docs/reference/input/compass-heading.md @@ -70,7 +70,7 @@ confuse the @boardname@. Keep the calibration handy by running it when the user pressed **A+B**. ```block -input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { input.calibrateCompass(); }) ``` diff --git a/docs/reference/input/light-level.md b/docs/reference/input/light-level.md index efb3511a..9e5ac8ba 100644 --- a/docs/reference/input/light-level.md +++ b/docs/reference/input/light-level.md @@ -29,7 +29,7 @@ program shows the light level on the [LED screen](/device/screen). ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { let level = input.lightLevel() basic.showNumber(level) }) diff --git a/docs/reference/input/on-button-pressed.md b/docs/reference/input/on-button-pressed.md index e6a84638..585cd930 100644 --- a/docs/reference/input/on-button-pressed.md +++ b/docs/reference/input/on-button-pressed.md @@ -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. ```sig -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {}) +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {}) ``` 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 let count = 0 basic.showNumber(count) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { count++; basic.showNumber(count); }) @@ -35,7 +35,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { This example shows a number from 1 to 6 when you press the `B` button. ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { let dice = Math.randomRange(0, 5) + 1 basic.showNumber(dice) }) diff --git a/docs/reference/input/running-time.md b/docs/reference/input/running-time.md index 231c6d2c..67027af6 100644 --- a/docs/reference/input/running-time.md +++ b/docs/reference/input/running-time.md @@ -18,7 +18,7 @@ program finds the number of milliseconds since the program started and shows it on the [LED screen](/device/screen). ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { let now = input.runningTime() basic.showNumber(now) }) diff --git a/docs/reference/led/enable.md b/docs/reference/led/enable.md index 4d5d76f0..f78eacd2 100644 --- a/docs/reference/led/enable.md +++ b/docs/reference/led/enable.md @@ -15,7 +15,7 @@ led.enable(false); This program turns off the screen when pressing button ``B`` ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { led.enable(false) }); ``` diff --git a/docs/reference/led/stop-animation.md b/docs/reference/led/stop-animation.md index 0591d132..a6f7149c 100644 --- a/docs/reference/led/stop-animation.md +++ b/docs/reference/led/stop-animation.md @@ -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``. ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { led.stopAnimation(); }); basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?"); diff --git a/docs/reference/music/on-event.md b/docs/reference/music/on-event.md index ebef64cd..0506df9c 100644 --- a/docs/reference/music/on-event.md +++ b/docs/reference/music/on-event.md @@ -43,7 +43,7 @@ music.onEvent(MusicEvent.BackgroundMelodyResumed, () => { music.onEvent(MusicEvent.BackgroundMelodyRepeated, () => { serial.writeLine("background repeated") }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { music.beginMelody(music.builtInMelody(Melodies.BaDing), MelodyOptions.Once) }) music.setTempo(100) diff --git a/docs/reference/music/set-play-tone.md b/docs/reference/music/set-play-tone.md index 2b48e192..f954e05d 100644 --- a/docs/reference/music/set-play-tone.md +++ b/docs/reference/music/set-play-tone.md @@ -17,7 +17,7 @@ This example send the frequency and duration over radio and plays it on the remote @boardname@. ```typescript -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { music.playTone(440, 120) led.toggle(0, 0) }) @@ -26,7 +26,7 @@ radio.onReceivedNumber(function (receivedNumber) { const duration = receivedNumber & 0xffff; music.playTone(freq, duration); }) -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { music.setPlayTone((frequency: number, duration: number) => { radio.sendNumber((frequency << 16) | (duration & 0xffff)); }) diff --git a/docs/reference/pins/digital-read-pin.md b/docs/reference/pins/digital-read-pin.md index f04ac892..b2832a2e 100644 --- a/docs/reference/pins/digital-read-pin.md +++ b/docs/reference/pins/digital-read-pin.md @@ -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@. ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { pins.digitalWritePin(DigitalPin.P1, 1); basic.pause(500); pins.digitalWritePin(DigitalPin.P1, 0); diff --git a/docs/reference/pins/digital-write-pin.md b/docs/reference/pins/digital-write-pin.md index 39e79ff6..3841a927 100644 --- a/docs/reference/pins/digital-write-pin.md +++ b/docs/reference/pins/digital-write-pin.md @@ -46,7 +46,7 @@ will use ``digital write pin`` to make the other @boardname@ buzz and make the score bigger. ```blocks -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { pins.digitalWritePin(DigitalPin.P1, 1); basic.pause(500); pins.digitalWritePin(DigitalPin.P1, 0); diff --git a/docs/reference/radio/receive-string.md b/docs/reference/radio/receive-string.md index b656dcf8..bbe79cc6 100644 --- a/docs/reference/radio/receive-string.md +++ b/docs/reference/radio/receive-string.md @@ -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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendString("Codeword: TRIMARAN") basic.showString("SENT"); }) @@ -59,10 +59,10 @@ This program will also receive your friend's mood. ```blocks let data: string = ""; -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendString("H"); }); -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { radio.sendString("S"); }); radio.onDataReceived(() => { diff --git a/docs/reference/radio/send-number.md b/docs/reference/radio/send-number.md index 4abae55a..758fd179 100644 --- a/docs/reference/radio/send-number.md +++ b/docs/reference/radio/send-number.md @@ -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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendNumber(input.acceleration(Dimension.X)) }) ``` diff --git a/docs/reference/radio/send-string.md b/docs/reference/radio/send-string.md index 268b07ce..a4fd4dda 100644 --- a/docs/reference/radio/send-string.md +++ b/docs/reference/radio/send-string.md @@ -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. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendString("Codeword: TRIMARAN") basic.showString("SENT"); }) diff --git a/docs/reference/radio/send-value.md b/docs/reference/radio/send-value.md index 262bd8a5..c6985098 100644 --- a/docs/reference/radio/send-value.md +++ b/docs/reference/radio/send-value.md @@ -29,7 +29,7 @@ or model rocket. ```blocks radio.setGroup(99) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendValue("acc", input.acceleration(Dimension.X)) }) ``` diff --git a/docs/reference/radio/write-value-to-serial.md b/docs/reference/radio/write-value-to-serial.md index 7066b199..5b9d0a08 100644 --- a/docs/reference/radio/write-value-to-serial.md +++ b/docs/reference/radio/write-value-to-serial.md @@ -29,7 +29,7 @@ the second @boardname@), this program sends temperature data to serial. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendNumber(input.temperature()); }); radio.onDataReceived(() => { diff --git a/docs/reference/serial/redirect.md b/docs/reference/serial/redirect.md index 815acf4e..80928fa7 100644 --- a/docs/reference/serial/redirect.md +++ b/docs/reference/serial/redirect.md @@ -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`. ```blocks -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600); }); ``` diff --git a/docs/types/buffer/using-buffers.md b/docs/types/buffer/using-buffers.md index 933c4038..c5711a64 100644 --- a/docs/types/buffer/using-buffers.md +++ b/docs/types/buffer/using-buffers.md @@ -57,7 +57,7 @@ You could simply save the light measurements in an array like this: ```blocks let darkness: number[] = [] -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { for (let i = 0; i < 60 * 4; i++) { darkness.push(input.lightLevel()) 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 let darkness = pins.createBuffer(60 * 4); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { for (let i = 0; i < 60 * 4; i++) { darkness.setNumber(NumberFormat.UInt8LE, i, input.lightLevel()) basic.pause(60000) @@ -90,7 +90,7 @@ Later, we can upload the file to the laptop computer by pressing the **B** butto ```typescript-ignore let dataReady = false; let darkness = pins.createBuffer(60 * 4); -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { for (let i = 0; i < 60 * 4; i++) { darkness.setNumber(NumberFormat.UInt8LE, i, input.lightLevel()) basic.pause(60000) @@ -98,7 +98,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { dataReady = true; }) -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { if (dataReady) { serial.writeLine("Transferring file: DARKNESS, Length: " + darkness.length + " bytes..."); serial.writeBuffer(darkness) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 8457eb80..43959355 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -388,7 +388,7 @@ "input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.", "input.onLogoUp|param|body": "TODO", "input.onPinEvent": "Do something when a pin is touched and released again (while also touching the GND pin).", - "input.onPinEvent|param|body": "the code to run when the pin is pressed", + "input.onPinEvent|param|body": "the code to run when event is fired on pin", "input.onPinEvent|param|name": "the pin, eg: TouchPin.P0", "input.onScreenDown": "Attaches code to run when the screen is facing down.", "input.onScreenDown|param|body": "TODO", diff --git a/libs/core/game.ts b/libs/core/game.ts index 573d79c5..6da731d0 100644 --- a/libs/core/game.ts +++ b/libs/core/game.ts @@ -323,9 +323,9 @@ namespace game { } function unplugEvents(): void { - input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { }); - input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { }); - input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.onButtonEvent(Button.A, ButtonEvent.Click, () => { }); + input.onButtonEvent(Button.B, ButtonEvent.Click, () => { }); + input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { control.reset(); }); } diff --git a/libs/core/input.cpp b/libs/core/input.cpp index b021a8ed..2583c3e2 100644 --- a/libs/core/input.cpp +++ b/libs/core/input.cpp @@ -230,9 +230,9 @@ namespace input { /** * Do something when a pin is touched and released again (while also touching the GND pin). * @param name the pin, eg: TouchPin.P0 - * @param body the code to run when the pin is pressed + * @param body the code to run when event is fired on pin */ - //% help=input/on-pin-pressed weight=83 blockGap=32 + //% help=input/on-pin-event weight=83 blockGap=32 //% blockId=device_pin_event block="on pin %name|is %eventType=control_button_event_value_id" void onPinEvent(TouchPin name, int eventType, Action body) { auto pin = getPin((int)name); diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index f6476d29..4bcd4b71 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -257,9 +257,9 @@ declare namespace input { /** * Do something when a pin is touched and released again (while also touching the GND pin). * @param name the pin, eg: TouchPin.P0 - * @param body the code to run when the pin is pressed + * @param body the code to run when event is fired on pin */ - //% help=input/on-pin-pressed weight=83 blockGap=32 + //% help=input/on-pin-event weight=83 blockGap=32 //% blockId=device_pin_event block="on pin %name|is %eventType=control_button_event_value_id" shim=input::onPinEvent function onPinEvent(name: TouchPin, eventType: int32, body: () => void): void; diff --git a/sim/state/buttonpair.ts b/sim/state/buttonpair.ts index 25992d5d..3840359c 100644 --- a/sim/state/buttonpair.ts +++ b/sim/state/buttonpair.ts @@ -15,9 +15,9 @@ namespace pxsim.input { b.usesButtonAB = true; runtime.queueDisplayUpdate(); } - pxtcore.registerWithDal(button, DAL.MICROBIT_BUTTON_EVT_CLICK, handler); + pxtcore.registerWithDal(button, ButtonEvent.Click, handler); } - + export function buttonIsPressed(button: number): boolean { let b = board().buttonPairState; if (button == b.abBtn.id && !b.usesButtonAB) { diff --git a/sim/state/edgeconnector.ts b/sim/state/edgeconnector.ts index dcce65a5..b8618ada 100644 --- a/sim/state/edgeconnector.ts +++ b/sim/state/edgeconnector.ts @@ -13,7 +13,7 @@ namespace pxsim.input { if (!pin) return; pin.isTouched(); runtime.queueDisplayUpdate(); - pxtcore.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_CLICK, handler); + pxtcore.registerWithDal(pin.id, ButtonEvent.Click, handler); } // Deprecated diff --git a/tests/hat-game.ts b/tests/hat-game.ts index e3b45d11..7a659e21 100644 --- a/tests/hat-game.ts +++ b/tests/hat-game.ts @@ -7,7 +7,7 @@ let level: number let swapSpeed: number initializeGame() -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (ballRevealing) { index = index + 1 if (index > 2) { @@ -16,7 +16,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { basic.showString(cupSelect[index], 150) } }) -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { if (ballRevealing) { ballRevealing = false if (correctBall == index) { diff --git a/tests/meteorite.ts b/tests/meteorite.ts index 487cf117..dfb0a264 100644 --- a/tests/meteorite.ts +++ b/tests/meteorite.ts @@ -18,7 +18,7 @@ counter = 0 pause = 700 led.plot(oneX, oneY) led.plot(twoX, twoY) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (oneX > 0) { led.unplot(oneX, oneY) led.unplot(twoX, twoY) @@ -28,7 +28,7 @@ input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { led.plot(twoX, twoY) } }) -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { if (twoX < 4) { led.unplot(oneX, oneY) led.unplot(twoX, twoY) diff --git a/tests/pac-man-runaway.ts b/tests/pac-man-runaway.ts index 32a259f8..a0999ffa 100644 --- a/tests/pac-man-runaway.ts +++ b/tests/pac-man-runaway.ts @@ -107,12 +107,12 @@ basic.forever(() => { basic.pause(500) } }) -input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { let temp = Math.abs(person.dirX) * (-1) person.dirX = Math.abs(person.dirY) * (-1) person.dirY = temp }) -input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { +input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { let temp1 = Math.abs(person.dirX) person.dirX = Math.abs(person.dirY) person.dirY = temp1 diff --git a/tests/wg-canoe-polo-timer.ts b/tests/wg-canoe-polo-timer.ts index 3e568fe8..c7f65e10 100644 --- a/tests/wg-canoe-polo-timer.ts +++ b/tests/wg-canoe-polo-timer.ts @@ -24,13 +24,13 @@ playOneGame(gameTime) showFinalScores(scoreA, scoreB) function startIOMonitor() { - input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { AWasPressed = true }) - input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { BWasPressed = true }) - input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { ABWasPressed = true AWasPressed = false BWasPressed = false diff --git a/tests/wg-dr-who.ts b/tests/wg-dr-who.ts index 835ce68f..f41e7be7 100644 --- a/tests/wg-dr-who.ts +++ b/tests/wg-dr-who.ts @@ -501,13 +501,13 @@ function convertPenaltyTimeToScore(penaltyTime: number): number { } function startIOMonitor() { - input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { AWasPressed = true }) - input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { BWasPressed = true }) - input.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { ABWasPressed = true }) input.onShake(() => { diff --git a/tests/wg-operation.ts b/tests/wg-operation.ts index 8d38a7f4..e5be568b 100644 --- a/tests/wg-operation.ts +++ b/tests/wg-operation.ts @@ -377,11 +377,11 @@ function beepNTimesFor(times: number, duration: number) { function startIOMonitor() { aWasPressed = false - input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { aWasPressed = true }) bWasPressed = false - input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { bWasPressed = true }) wasTweezers = false diff --git a/tests/wg-user-confidance.ts b/tests/wg-user-confidance.ts index 5420bf81..83b9b188 100644 --- a/tests/wg-user-confidance.ts +++ b/tests/wg-user-confidance.ts @@ -476,10 +476,10 @@ function testTiltZ() { } function startIOMonitor() { - input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => { AWasPressed = true }) - input.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => { + input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => { BWasPressed = true }) input.onShake(() => {