diff --git a/docs/about.md b/docs/about.md index 3eb4ec74..8f1673dc 100644 --- a/docs/about.md +++ b/docs/about.md @@ -26,12 +26,12 @@ The Calliope mini is packaged with sensors, radio and other goodies. Learn about You can program the Calliope mini using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser via the [Calliope mini APIs](/reference): ```block -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { basic.showString("Hi!"); }) ``` ```typescript -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { basic.showString("Hi!"); }) ``` @@ -54,7 +54,7 @@ The simulator has support for the LED screen, buttons, as well as compass, accel basic.forever(() => { basic.showString("Hi!"); }) -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { led.stopAnimation(); basic.showLeds(` . . . . . @@ -63,7 +63,7 @@ input.onButtonPressed(Button.A, () => { # . . . # . # # # .`); }); -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Down, () => { led.stopAnimation(); basic.showLeds(` . # . # . diff --git a/docs/blocks/logic/boolean.md b/docs/blocks/logic/boolean.md index 350626f4..3323994e 100644 --- a/docs/blocks/logic/boolean.md +++ b/docs/blocks/logic/boolean.md @@ -17,7 +17,7 @@ if (led.point(1,1) && led.point(2,2)) { When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below: ```blocks -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { let x = randint(0, 5) if(x < 5) { basic.showString("low"); diff --git a/docs/blocks/logic/if.md b/docs/blocks/logic/if.md index c3d0d837..0e33c943 100644 --- a/docs/blocks/logic/if.md +++ b/docs/blocks/logic/if.md @@ -7,7 +7,7 @@ If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed: ```blocks -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { if(input.lightLevel()<100){ led.setBrightness(255); } diff --git a/docs/blocks/loops/for.md b/docs/blocks/loops/for.md index 1f4faf2b..68919471 100644 --- a/docs/blocks/loops/for.md +++ b/docs/blocks/loops/for.md @@ -7,7 +7,7 @@ This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen. ```blocks -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { for(let i = 0; i < 5; ++i) { basic.showNumber(i) } diff --git a/docs/blocks/loops/while.md b/docs/blocks/loops/while.md index f6f3e569..60e886fe 100644 --- a/docs/blocks/loops/while.md +++ b/docs/blocks/loops/while.md @@ -7,7 +7,7 @@ The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`). ```blocks -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { let index = 4; while(index >= 0) { led.plot(index, index); diff --git a/docs/blocks/on-start.md b/docs/blocks/on-start.md index 8c56977c..c0f746fb 100644 --- a/docs/blocks/on-start.md +++ b/docs/blocks/on-start.md @@ -5,7 +5,7 @@ In this example, ``on start`` sets a dimmer brightness on the screen and the button handler shows a string. ```blocks -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { basic.showString("Hello!") }) led.setBrightness(50) diff --git a/docs/blocks/variables/var.md b/docs/blocks/variables/var.md index d149e444..20d3b6cd 100644 --- a/docs/blocks/variables/var.md +++ b/docs/blocks/variables/var.md @@ -59,7 +59,7 @@ A counter is a great example: ```blocks let counter = 0; -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { counter = counter + 1; basic.showNumber(counter); }); diff --git a/docs/device/crocodile-clips.md b/docs/device/crocodile-clips.md index 8664df59..4e7d28a8 100644 --- a/docs/device/crocodile-clips.md +++ b/docs/device/crocodile-clips.md @@ -38,7 +38,7 @@ Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the @boardname@ will return a random Number between 0 and the parameter limit. ```blocks -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { basic.showNumber(randint(0, 10)) }) ``` diff --git a/docs/device/data-analysis/led-plotting.md b/docs/device/data-analysis/led-plotting.md index 6fb0f629..d0914ec3 100644 --- a/docs/device/data-analysis/led-plotting.md +++ b/docs/device/data-analysis/led-plotting.md @@ -63,7 +63,7 @@ for (let i = 0; i < values.length; i++) { The ``||led:plot bar graph||`` also sends the number value it's plotting to the console. You can see the output in the Data Viewer. It charts the values and they appear as individual numbers in console. ```blocks -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { for (let i = 0; i < 25; i++) { if (i % 2 > 0) { led.plotBarGraph(0, 0) diff --git a/docs/device/reactive.md b/docs/device/reactive.md index 5f0c32b8..b5a9c6b2 100644 --- a/docs/device/reactive.md +++ b/docs/device/reactive.md @@ -51,7 +51,7 @@ The first job of the scheduler is to allow multiple *subprograms* to be queued u ```typescript let count = 0 -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { count++; }) @@ -74,7 +74,7 @@ The second statement informs the scheduler that on each and every event of the * // statement 1 let count = 0 // statement 2 -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { count++; }) ``` @@ -85,7 +85,7 @@ The third statement queues a `forever` loop for later execution by the scheduler // statement 1 let count = 0 // statement 2 -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { count++; }) // statement 3 @@ -157,7 +157,7 @@ As a result, you can easily add a new capability to the micro:bit by just adding ```typescript let count = 0 -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { count = count + 1 }) @@ -165,7 +165,7 @@ basic.forever(() => { basic.showNumber(count) }) -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Down, () => { count = 0 }) ``` diff --git a/docs/device/serial.md b/docs/device/serial.md index 8f9499ac..11b6ff48 100644 --- a/docs/device/serial.md +++ b/docs/device/serial.md @@ -6,7 +6,7 @@ The code below shows a simple script that sends a line when the BBC micro:bit st ```blocks serial.writeLine("started...") -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { serial.writeLine("A pressed") }) ``` diff --git a/docs/device/simulator.md b/docs/device/simulator.md index f1f99a0d..bbd74ca2 100644 --- a/docs/device/simulator.md +++ b/docs/device/simulator.md @@ -4,19 +4,19 @@ The JavaScript simulator allows you to test and execute most BBC micro:bit progr It allows you to emulate sensor data or user interactions. ```sim -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("A"); }); -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { basic.showString("B"); }); -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => { basic.showString("0"); }); -input.onPinPressed(TouchPin.P1, () => { +input.onPinTouchEvent(TouchPin.P1, ButtonEvent.Click, () => { basic.showString("1"); }); -input.onPinPressed(TouchPin.P2, () => { +input.onPinTouchEvent(TouchPin.P2, ButtonEvent.Click, () => { basic.showString("2"); }); input.temperature() diff --git a/docs/examples/gameofLife.md b/docs/examples/gameofLife.md index 0da12a30..93a6b049 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { gameOfLife(); show(); }) //Use button B for reseting to random initial seed state -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { reset(); show(); }) diff --git a/docs/projects/coin-flipper.md b/docs/projects/coin-flipper.md index f82a7480..5a9e1f6d 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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (Math.randomBoolean()) { } 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``. ```blocks -input.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showIcon(IconNames.Diamond) basic.showIcon(IconNames.SmallDiamond) basic.showIcon(IconNames.Diamond) diff --git a/docs/projects/love-meter.md b/docs/projects/love-meter.md index 64ef21cb..fb3dff23 100644 --- a/docs/projects/love-meter.md +++ b/docs/projects/love-meter.md @@ -11,7 +11,7 @@ Make a love meter, how sweet! The @boardname@ is feeling the love, then sometime 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 -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { }); ``` @@ -20,7 +20,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. ```blocks -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { basic.showNumber(randint(0, 100)); }); ``` @@ -34,7 +34,7 @@ Show ``"LOVE METER"`` on the screen when the @boardname@ starts. ```blocks basic.showString("LOVE METER"); -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { basic.showNumber(randint(0, 100)); }); ``` diff --git a/docs/projects/mini-chat.md b/docs/projects/mini-chat.md index 4695e152..9d48507c 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { radio.sendString("Yo"); }); radio.onReceivedString(function (receivedString) { diff --git a/docs/projects/name-badge.md b/docs/projects/name-badge.md index a58f8505..cebbd7ef 100644 --- a/docs/projects/name-badge.md +++ b/docs/projects/name-badge.md @@ -13,7 +13,7 @@ First, let's get your name to display on the screen. From the ``||input:Input||`` Toolbox drawer, drag an ``||input:on button A pressed||`` block onto the Workspace. ```blocks -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { }) ``` @@ -23,7 +23,7 @@ input.onButtonPressed(Button.A, function () { From the ``||basic:Basic||`` Toolbox drawer drag a ``||basic:show string||`` block into the ``||input:on button A pressed||`` block. ```blocks -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { basic.showString("Hello!") }) ``` @@ -33,7 +33,7 @@ input.onButtonPressed(Button.A, function () { In the ``||basic:show string||`` block, type your name. ```blocks -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { basic.showString("My Name") }) ``` @@ -43,7 +43,7 @@ input.onButtonPressed(Button.A, function () { Go to the simulator and test your name badge by pressing button **A**. ```sim -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { basic.showString("My Name") }) ``` diff --git a/docs/projects/robot-unicorn.md b/docs/projects/robot-unicorn.md index 46562447..d70af286 100644 --- a/docs/projects/robot-unicorn.md +++ b/docs/projects/robot-unicorn.md @@ -123,7 +123,7 @@ basic.forever(function () { **MakeCode blocks for the Robot Unicorn controller** ```blocks -input.onButtonPressed(Button.AB, function () { +input.onButtonEvent(Button.AB, ButtonEvent.Down, function () { radio.sendNumber(4) basic.showLeds(` # . . . # diff --git a/docs/projects/rotary-dial-radio.md b/docs/projects/rotary-dial-radio.md index f870aef8..15bf3ea4 100644 --- a/docs/projects/rotary-dial-radio.md +++ b/docs/projects/rotary-dial-radio.md @@ -83,7 +83,7 @@ Now that we are detecting pulses, we can use a variable to count them too. In th ```blocks let pulseCount = 0 -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Down, function () { basic.showNumber(pulseCount) pulseCount = 0 }) diff --git a/docs/projects/smiley-buttons.md b/docs/projects/smiley-buttons.md index 271560f6..1cacea48 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.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. ```blocks -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 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. ```blocks -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { 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. ```blocks -input.onButtonPressed(Button.AB, () => { +input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { basic.showLeds(` . . . . . # . # . . diff --git a/docs/projects/snap-the-dot.md b/docs/projects/snap-the-dot.md index 5d3a0f55..3a628e45 100644 --- a/docs/projects/snap-the-dot.md +++ b/docs/projects/snap-the-dot.md @@ -59,7 +59,7 @@ Use a ``||input:on button pressed||`` block to handle the **A** button. Put in a ```blocks let sprite = game.createSprite(2, 2) -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { if (sprite.get(LedSpriteProperty.X) == 2) { } else { } @@ -77,7 +77,7 @@ Finally, pull out an ``||game:add score||`` and a ``||game:game over||`` block t ```blocks let sprite = game.createSprite(2, 2) -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { if (sprite.get(LedSpriteProperty.X) == 2) { game.addScore(1) } else { diff --git a/docs/reference/basic.md b/docs/reference/basic.md index aceb095b..c42fc82d 100644 --- a/docs/reference/basic.md +++ b/docs/reference/basic.md @@ -18,7 +18,7 @@ basic.forever(() => { }); basic.pause(100); -basic.showArrow(ArrowNames.North); +basic.showIcon(IconNames.ArrowNorth); ``` ## See also @@ -27,4 +27,4 @@ basic.showArrow(ArrowNames.North); [showIcon](/reference/basic/show-icon), [showLeds](/reference/basic/show-leds), [showString](/reference/basic/show-string), [clearScreen](/reference/basic/clear-screen), [forever](/reference/basic/forever), [pause](/reference/basic/pause), -[showArrow](/reference/basic/show-arrow), [showAnimation](/reference/basic/show-animation) +[showAnimation](/reference/basic/show-animation) diff --git a/docs/reference/basic/forever.md b/docs/reference/basic/forever.md index c7f9bfb6..4babcb0a 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { num = num + 1 }) ``` @@ -59,7 +59,7 @@ Try this on your @boardname@: basic.forever(() => { basic.showNumber(6789) }) -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showNumber(2) }) ``` diff --git a/docs/reference/basic/show-arrow.md b/docs/reference/basic/show-arrow.md deleted file mode 100644 index 82f60f4d..00000000 --- a/docs/reference/basic/show-arrow.md +++ /dev/null @@ -1,29 +0,0 @@ -# Show Arrow - -Shows the selected arrow on the LED screen - -```sig -basic.showArrow(ArrowNames.North) -``` - - -## Parameters - -* ``direction``, the identifier of the arrow to display -* ``interval`` (optional), the time to display in milliseconds. default is 400. - -## Example - -This program shows all eight arrows. - -```blocks -for (let index = 0; index <= 7; index++) { - basic.showArrow(index) - basic.pause(300) -} -``` - -## See also - -[showIcon](/reference/basic/show-icon), -[showLeds](/reference/basic/show-leds) \ No newline at end of file diff --git a/docs/reference/bluetooth/stop-advertising.md b/docs/reference/bluetooth/stop-advertising.md index 2753a273..53b86468 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { bluetooth.stopAdvertising(); }) ``` diff --git a/docs/reference/bluetooth/uart-write-line.md b/docs/reference/bluetooth/uart-write-line.md index 5a24714d..405caddd 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { 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 695ac943..ab38750f 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { if (connected == 1) { bluetooth.uartWriteString("HELLO"); } diff --git a/docs/reference/control/in-background.md b/docs/reference/control/in-background.md index 7ac747c5..2851ed8b 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { num++; }) ``` @@ -42,7 +42,7 @@ let num = 0 basic.forever(() => { basic.showNumber(num) }) -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { num++; }) ``` diff --git a/docs/reference/control/reset.md b/docs/reference/control/reset.md index 8131c07a..c7743adf 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { item = item + 1; basic.showNumber(item); }); -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Down, () => { control.reset(); }); ``` diff --git a/docs/reference/event-handler.md b/docs/reference/event-handler.md index 0027a7a1..65fcdde3 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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("hello", 150) }) -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 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: ```blocks -input.onButtonPressed(Button.A, () => { +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 70b5e2f4..845a4eef 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.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Down, () => { basic.showNumber(game.score()) game.setScore(0) }) -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { game.addScore(1) }) ``` diff --git a/docs/reference/game/change-score-by.md b/docs/reference/game/change-score-by.md index a3cb236e..2cc54d5a 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { game.addScore(1) }) game.startCountdown(10000) diff --git a/docs/reference/game/clear.md b/docs/reference/game/clear.md index 93b89c15..f9c86ca4 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { img.clear() img.showImage(0) }) diff --git a/docs/reference/game/game-over.md b/docs/reference/game/game-over.md index 2e50fea5..9347c3e2 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { basic.showString("YOU WIN!"); }); -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Down, () => { game.gameOver(); }); ``` diff --git a/docs/reference/game/if-on-edge-bounce.md b/docs/reference/game/if-on-edge-bounce.md index 841eaf5a..65a9e3cb 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.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Down, () => { ball.ifOnEdgeBounce(); basic.showNumber(ball.get(LedSpriteProperty.Direction)); }); diff --git a/docs/reference/game/is-paused.md b/docs/reference/game/is-paused.md index 7f497d5d..6de3ddf2 100644 --- a/docs/reference/game/is-paused.md +++ b/docs/reference/game/is-paused.md @@ -15,7 +15,7 @@ game.isPaused() Resume the game if it's paused and button **B** is pressed. ```blocks -input.onButtonPressed(Button.B, function () { +input.onButtonEvent(Button.B, ButtonEvent.Down, function () { if (game.isPaused()) { game.resume() } diff --git a/docs/reference/game/is-running.md b/docs/reference/game/is-running.md index 40ee9565..2ceba3f3 100644 --- a/docs/reference/game/is-running.md +++ b/docs/reference/game/is-running.md @@ -15,7 +15,7 @@ game.isRunning() If the game is currently running, end the game if button **B** is pressed. ```blocks -input.onButtonPressed(Button.B, function () { +input.onButtonEvent(Button.B, ButtonEvent.Click, function () { if (game.isRunning()) { game.gameOver() } diff --git a/docs/reference/game/score.md b/docs/reference/game/score.md index b2fe712a..123fc8e7 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Down, () => { 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 e6cda6e6..b51e3a1a 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.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { basic.showNumber(game.score()) game.setScore(0) }) -input.onButtonPressed(Button.A, () => { +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 89ca2a77..d5cc0178 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { game.addScore(1) }) game.startCountdown(10000) diff --git a/docs/reference/images.md b/docs/reference/images.md index 9ea3794a..8898b8a4 100644 --- a/docs/reference/images.md +++ b/docs/reference/images.md @@ -19,14 +19,12 @@ images.createBigImage(` `); images.createImage(``).showImage(0); images.createImage(``).scrollImage(0,0); -images.arrowImage(ArrowNames.North) images.iconImage(IconNames.Heart) -images.arrowNumber(ArrowNames.North) ``` ## See Also [createImage](/reference/images/create-image), [createBigImage](/reference/images/create-big-image), [showImage](/reference/images/show-image), [scrollImage](/reference/images/scroll-image), -[arrowImage](/reference/images/arrow-image), [iconImage](/reference/images/icon-image), [arrowNumber](/reference/images/arrow-number), +[iconImage](/reference/images/icon-image), [pixel](/reference/images/pixel), [set-pixel](/reference/images/set-pixel) diff --git a/docs/reference/images/arrow-image.md b/docs/reference/images/arrow-image.md deleted file mode 100644 index 98b8c36c..00000000 --- a/docs/reference/images/arrow-image.md +++ /dev/null @@ -1,41 +0,0 @@ -# arrow Image - -Create an arrow shaped [image](/reference/images/image) for the [LED screen](/device/screen). - -```sig -images.arrowImage(ArrowNames.North) -``` - -The arrow points in the direction of the arrow name you choose, like `North`. - -## Parameters - -* **i**: the arrow name to make an arrow [image](/reference/images/image) for. You can make an arrow image that points in one of these directions: - ->* `North` ->* `NorthEast` ->* `East` ->* `SouthEast` ->* `South` ->* `SouthWest` ->* `West` ->* `NorthWest` - -## Example - -Display a left arrow when button A is pressed or a right arrow when button B is pressed. - -```blocks -let arrowLeft = images.arrowImage(ArrowNames.West) -let arrowRight = images.arrowImage(ArrowNames.East) - -input.onButtonPressed(Button.A, () => { - arrowLeft.showImage(0); -}); -input.onButtonPressed(Button.B, () => { - arrowRight.showImage(0); -}); -``` -## See also - -[arrow number](/reference/images/arrow-number) diff --git a/docs/reference/images/arrow-number.md b/docs/reference/images/arrow-number.md deleted file mode 100644 index 710325c5..00000000 --- a/docs/reference/images/arrow-number.md +++ /dev/null @@ -1,33 +0,0 @@ -# arrow Number - -Get the number that matches an arrow image name. - -```sig -images.arrowNumber(ArrowNames.North) -``` - -Each arrow image name has a number for it. You can find the number for any arrow name with ``||Images:arrow number||``. - -## Parameters - -* **arrow**: the arrow name to get an arrow number for. These are the arrow names: - ->* `North` -* `NorthEast` -* `East` -* `SouthEast` -* `South` -* `SouthWest` -* `West` -* `NorthWest` - -## Example - -Get the arrow number for `ArrowNames.South`. - -```blocks -let arrowSouthNumber = images.arrowNumber(ArrowNames.South) -``` -## See also - -[arrow image](/reference/images/arrow-image) \ No newline at end of file diff --git a/docs/reference/images/create-big-image.md b/docs/reference/images/create-big-image.md index c5c75db1..5fd3ced8 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { arrows.showImage(0); }); -input.onButtonPressed(Button.B, () => { +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 d4ab2563..ce44163d 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { images.createImage(` . . # . . . # # # . @@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => { . . # . . `).showImage(0); }); -input.onButtonPressed(Button.B, () => { +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 d8ae4333..b6d48f51 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { iamHappy.showImage(0); }); -input.onButtonPressed(Button.B, () => { +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 3867e500..ae8dd6cf 100644 --- a/docs/reference/images/show-image.md +++ b/docs/reference/images/show-image.md @@ -31,10 +31,10 @@ let arrows = images.createBigImage(` . . # . . . # # # . . . # . . . . # . . `); -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { arrows.showImage(0); }); -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { arrows.showImage(5); }); ``` diff --git a/docs/reference/input.md b/docs/reference/input.md index 80920799..cb86edb4 100644 --- a/docs/reference/input.md +++ b/docs/reference/input.md @@ -3,13 +3,13 @@ Events and data from sensors ```cards -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { }); input.onGesture(Gesture.Shake, () => { }); -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => { }); input.buttonIsPressed(Button.A); diff --git a/docs/reference/input/calibrate-compass.md b/docs/reference/input/calibrate-compass.md index 6096a82b..71e86dcc 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.onButtonPressed(Button.AB, () => { +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 5696c29e..f13e2962 100644 --- a/docs/reference/input/compass-heading.md +++ b/docs/reference/input/compass-heading.md @@ -41,15 +41,15 @@ let degrees = 0 basic.forever(() => { degrees = input.compassHeading() if (degrees < 45) { - basic.showArrow(ArrowNames.North) + basic.showIcon(IconNames.ArrowNorth) } else if (degrees < 135) { - basic.showArrow(ArrowNames.East) + basic.showIcon(IconNames.ArrowEast) } else if (degrees < 225) { - basic.showArrow(ArrowNames.South) + basic.showIcon(IconNames.ArrowSouth) } else if (degrees < 315) { - basic.showArrow(ArrowNames.West) + basic.showIcon(IconNames.ArrowWest) } else { - basic.showArrow(ArrowNames.North) + basic.showIcon(IconNames.ArrowNorth) } }) ``` @@ -70,7 +70,7 @@ confuse the @boardname@. Keep the calibration handy by running it when the user pressed **A+B**. ```block -input.onButtonPressed(Button.AB, () => { +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 558aab08..52360fb5 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.onButtonPressed(Button.B, () => { +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 62331fcf..f47dbd8d 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.onButtonPressed(Button.A, () => {}) +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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 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. ```blocks -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { let dice = randint(0, 5) + 1 basic.showNumber(dice) }) diff --git a/docs/reference/input/on-pin-pressed.md b/docs/reference/input/on-pin-pressed.md index 7d384c6e..2be5ad16 100644 --- a/docs/reference/input/on-pin-pressed.md +++ b/docs/reference/input/on-pin-pressed.md @@ -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! ```sig -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => { }) ``` @@ -43,7 +43,7 @@ Every time you press the pin, the program shows the number of times on the scree ```blocks let count = 0 basic.showNumber(count) -input.onPinPressed(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => { count = count + 1 basic.showNumber(count) }) diff --git a/docs/reference/input/on-pin-released.md b/docs/reference/input/on-pin-released.md index 724a3282..92297cea 100644 --- a/docs/reference/input/on-pin-released.md +++ b/docs/reference/input/on-pin-released.md @@ -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! ```sig -input.onPinReleased(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => { }) ``` @@ -36,7 +36,7 @@ Every time you release the pin, the program shows the number of times on the scr ```blocks let count = 0 basic.showNumber(count, 100) -input.onPinReleased(TouchPin.P0, () => { +input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => { count = count + 1 basic.showNumber(count, 100) }) diff --git a/docs/reference/input/running-time.md b/docs/reference/input/running-time.md index 099fb640..6cc79d57 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.onButtonPressed(Button.B, () => { +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 9123e2fb..4e02db14 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.onButtonPressed(Button.B, () => { +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 050d0a2f..1cd9159f 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.onButtonPressed(Button.B, () => { +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 b6c0e7d0..00ecfbe8 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.onButtonPressed(Button.A, () => { +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 81c168cd..8d8f5347 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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.B, () => { +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 f3338b87..9b0d6955 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.onButtonPressed(Button.B, () => { +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 9b03fec0..2cc7a861 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.onButtonPressed(Button.B, () => { +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 3c6ae814..c5ecbb2c 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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendString("H"); }); -input.onButtonPressed(Button.B, () => { +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 15303c6f..a396efab 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.onButtonPressed(Button.A, () => { +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 07211194..75e295e1 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.onButtonPressed(Button.A, () => { +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 b3737c1b..bbcf4fd5 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { radio.sendValue("acc", input.acceleration(Dimension.X)) }) ``` diff --git a/docs/reference/radio/write-received-packet-to-serial.md b/docs/reference/radio/write-received-packet-to-serial.md index 26fc44b6..7d7ca22a 100644 --- a/docs/reference/radio/write-received-packet-to-serial.md +++ b/docs/reference/radio/write-received-packet-to-serial.md @@ -30,7 +30,7 @@ the second @boardname@), this program sends temperature data to the serial port. ```blocks -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { radio.sendNumber(input.temperature()) radio.sendValue("temp", input.temperature()) radio.sendString("It's warm now") diff --git a/docs/reference/radio/write-value-to-serial.md b/docs/reference/radio/write-value-to-serial.md index d3feb48e..c3b0815e 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.onButtonPressed(Button.A, () => { +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 4563c646..8a688b84 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600); }); ``` diff --git a/docs/reference/serial/write-line.md b/docs/reference/serial/write-line.md index 7e37741f..b8b4ecc8 100644 --- a/docs/reference/serial/write-line.md +++ b/docs/reference/serial/write-line.md @@ -34,19 +34,19 @@ let direction = "" basic.forever(() => { degrees = input.compassHeading() if (degrees < 45) { - basic.showArrow(ArrowNames.North) + basic.showIcon(IconNames.ArrowNorth) direction = "North" } else if (degrees < 135) { - basic.showArrow(ArrowNames.East) + basic.showIcon(IconNames.ArrowEast) direction = "East" } else if (degrees < 225) { - basic.showArrow(ArrowNames.South) + basic.showIcon(IconNames.ArrowSouth) direction = "South" } else if (degrees < 315) { - basic.showArrow(ArrowNames.West) + basic.showIcon(IconNames.ArrowWest) direction = "West" } else { - basic.showArrow(ArrowNames.North) + basic.showIcon(IconNames.ArrowNorth) direction = "North" } serial.writeLine(direction + " @ " + degrees + " degrees") diff --git a/docs/tutorials/getting-started.md b/docs/tutorials/getting-started.md index 4252084e..3007a6de 100644 --- a/docs/tutorials/getting-started.md +++ b/docs/tutorials/getting-started.md @@ -13,7 +13,7 @@ basic.showString("Micro!") Well, the text stopped scrolling. Place the ``||basic:show string||`` block in the ``||input:on button pressed||`` slot to scroll your name when button **A** is pressed. ```blocks -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("Micro!") }); ``` @@ -25,7 +25,7 @@ Place some blocks to display a smiley when button **B** is pressed. Use the dropdown to find ``B``! ```blocks -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { basic.showLeds(` # # . # # # # . # # diff --git a/docs/tutorials/hour-of-code/hey-microbit.md b/docs/tutorials/hour-of-code/hey-microbit.md index f8057e71..353b2177 100644 --- a/docs/tutorials/hour-of-code/hey-microbit.md +++ b/docs/tutorials/hour-of-code/hey-microbit.md @@ -13,7 +13,7 @@ basic.showString("My Name") Well, you noticed that the text stopped. Place the ``||basic:show string||`` block in an ``||input:on button pressed||`` block to scroll your name whenever button **A** is pressed. ```block -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("My Name") }); ``` @@ -23,7 +23,7 @@ input.onButtonPressed(Button.A, () => { Ok, let's try to talk to the @boardname@ using a button. Change the text in ``||basic:show string||`` to ask the question "How are you?". Add another ``||basic:show string||`` with "....." to show that the @boardname@ is thinking. ```block -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("How are you?") basic.showString("....."); }) @@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => { Now, make the @boardname@ give an answer with a smiley face! Find the ``||basic:show leds||`` and draw a smiley face on the block by clicking on the LEDs. Press button **A** in the simulator and see the @boardname@ respond to your question. ```block -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString("How are you?") basic.showString("....."); basic.showLeds(` diff --git a/docs/types/buffer/using-buffers.md b/docs/types/buffer/using-buffers.md index 352d2fd6..5e112b7e 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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { +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.onButtonPressed(Button.A, () => { dataReady = true; }) -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { if (dataReady) { serial.writeLine("Transferring file: DARKNESS, Length: " + darkness.length + " bytes..."); serial.writeBuffer(darkness) diff --git a/editor/patch.ts b/editor/patch.ts index f1474a11..ddb1361d 100644 --- a/editor/patch.ts +++ b/editor/patch.ts @@ -1,3 +1,157 @@ + +export function patchBlocks(pkgTargetVersion: string, dom: Element) { + // is this a old script? + if (pxt.semver.majorCmp(pkgTargetVersion || "0.0.0", "4.0.20") >= 0) return; + // button and pin pressed/released blocks +/* + + Button.A + + + TouchPin.P0 + + + TouchPin.P1 + + + converts to + + + Button.B + + + ButtonEvent.Click + + + + + TouchPin.P2 + + + ButtonEvent.Up + + + +*/ +const inputNodes = pxt.U.toArray(dom.querySelectorAll("block[type=device_button_event]")) + .concat(pxt.U.toArray(dom.querySelectorAll("block[type=device_pin_event]"))) + .concat(pxt.U.toArray(dom.querySelectorAll("block[type=device_pin_released]"))) + inputNodes.forEach(node => { + const nodeType = node.getAttribute("type"); + if(nodeType === "device_button_event") { + node.setAttribute("type", "device_button_selected_event"); + } else { + node.setAttribute("type", "device_pin_custom_event"); + } + // fix lowercase 'name'in device_pin_event + if(nodeType === "device_pin_event") { + node.querySelectorAll("field[name=name]")[0].setAttribute("name", "NAME") + } + const valueNode = node.ownerDocument.createElement("value"); + valueNode.setAttribute("name", "eventType") + + const shadowNode = node.ownerDocument.createElement("shadow"); + shadowNode.setAttribute("type", "control_button_event_value_id") + + const fieldNode = node.ownerDocument.createElement("field"); + fieldNode.setAttribute("name", "id") + + if(nodeType === "device_button_event") { + fieldNode.textContent = "ButtonEvent.Click"; + } else if(nodeType === "device_pin_released") { + fieldNode.textContent = "ButtonEvent.Up"; + } else { + fieldNode.textContent = "ButtonEvent.Down"; + } + + shadowNode.prepend(fieldNode) + valueNode.prepend(shadowNode) + node.prepend(valueNode) + + }); + + + +// loudness + /* + + + converts to + + + */ + const loudnessNodes = pxt.U.toArray(dom.querySelectorAll("block[type=loudness]")) + loudnessNodes.forEach(node => { + node.setAttribute("type", "soundLevel"); + }); + + // rgbw to rgb block + const rgbwNodes = pxt.U.toArray(dom.querySelectorAll("block[type=core_rgbw]")) + rgbwNodes.forEach(node => { + node.setAttribute("type", "core_rgb"); + node.querySelectorAll("value[name=white]")[0].remove(); + }); + + // arrow blocks + /* + + + + ArrowNames.North + + + + + converts to + + + + IconNames.ArrowNorth + + */ +const arrowNodes = pxt.U.toArray(dom.querySelectorAll("block[type=basic_show_arrow]")) +arrowNodes.forEach(node => { + node.setAttribute("type", "basic_show_icon"); + const arrowNode = node.querySelectorAll("value[name=i]")[0] + const iconName = "IconNames.Arrow" + arrowNode.querySelectorAll("field[name=arrow]")[0].textContent.split('.')[1]; + + const iconNode = node.ownerDocument.createElement("field"); + iconNode.setAttribute("name", "i") + iconNode.textContent = iconName; + + const mutationNode = node.ownerDocument.createElement("mutation"); + // mutationNode.setAttribute("xmlns", "http://www.w3.org/1999/xhtml") + mutationNode.setAttribute("_expanded", "0") + mutationNode.setAttribute("_input_init", "false") + + node.prepend(iconNode) + node.prepend(mutationNode) + node.removeChild(arrowNode); +}); + + // arrow icons + /* + + ArrowNames.East + + + converts to + + + IconNames.ArrowEast + + */ +const arrowImageNodes = pxt.U.toArray(dom.querySelectorAll("block[type=builtin_arrow_image]")) +arrowImageNodes.forEach(node => { + node.setAttribute("type", "builtin_image"); + const arrowNode = node.querySelectorAll("field[name=i]")[0]; + arrowNode.textContent = "IconNames.Arrow" + arrowNode.textContent.split('.')[1]; +}); + + // is this a very old script? + if (pxt.semver.majorCmp(pkgTargetVersion || "0.0.0", "1.0.0") >= 0) return; + + // LEDs /** * FALSE @@ -40,11 +194,6 @@ */ -export function patchBlocks(pkgTargetVersion: string, dom: Element) { - // is this a old script? - if (pxt.semver.majorCmp(pkgTargetVersion || "0.0.0", "1.0.0") >= 0) return; - - // showleds const nodes = pxt.U.toArray(dom.querySelectorAll("block[type=device_show_leds]")) .concat(pxt.U.toArray(dom.querySelectorAll("block[type=device_build_image]"))) .concat(pxt.U.toArray(dom.querySelectorAll("shadow[type=device_build_image]"))) @@ -62,7 +211,7 @@ export function patchBlocks(pkgTargetVersion: string, dom: Element) { let n = lednode.getAttribute("name"); let col = parseInt(n[3]); let row = parseInt(n[4]); - leds[row][col] = lednode.innerHTML == "TRUE" ? "#" : "."; + leds[row][col] = lednode.textContent == "TRUE" ? "#" : "."; // remove node node.removeChild(lednode); }); @@ -74,6 +223,8 @@ export function patchBlocks(pkgTargetVersion: string, dom: Element) { node.insertBefore(f, null); }); + + // radio /* @@ -113,7 +264,7 @@ converts to node.appendChild(f); } - pxt.U.toArray(dom.querySelectorAll("variable")).forEach(node => varids[node.innerHTML] = node.getAttribute("id")); + pxt.U.toArray(dom.querySelectorAll("variable")).forEach(node => varids[node.textContent] = node.getAttribute("id")); pxt.U.toArray(dom.querySelectorAll("block[type=radio_on_packet]")) .forEach(node => { const mutation = node.querySelector("mutation"); diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index cea6acdd..d1dc3163 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -254,11 +254,6 @@ "basic.plotLeds": "Draws an image on the LED screen.", "basic.plotLeds|param|leds": "pattern of LEDs to turn on/off", "basic.rgb": "Converts red, green, blue channels into a RGB color", - "basic.rgbw": "Converts red, green, blue channels into a RGB color", - "basic.rgbw|param|blue": "value of the blue channel between 0 and 255. eg: 255", - "basic.rgbw|param|green": "value of the green channel between 0 and 255. eg: 255", - "basic.rgbw|param|red": "value of the red channel between 0 and 255. eg: 255", - "basic.rgbw|param|white": "value of the white channel between 0 and 255. eg: 0", "basic.rgb|param|blue": "value of the blue channel between 0 and 255. eg: 255", "basic.rgb|param|green": "value of the green channel between 0 and 255. eg: 255", "basic.rgb|param|red": "value of the red channel between 0 and 255. eg: 255", @@ -441,25 +436,15 @@ "input.isGesture": "Tests if a gesture is currently detected.", "input.isGesture|param|gesture": "the type of gesture to detect, eg: Gesture.Shake", "input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.", - "input.loudness": "gets the level of loudness from 0 (silent) to 255 (loud)", "input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.", "input.magneticForce|param|dimension": "the x, y, or z dimension, eg: Dimension.X", "input.onButtonEvent": "Do something when a button (A, B or both A+B) receives an event.", "input.onButtonEvent|param|body": "code to run when event is raised", "input.onButtonEvent|param|button": "the button", "input.onButtonEvent|param|eventType": "event Type", - "input.onButtonPressed": "Do something when a button (A, B or both A+B) is pushed down and released again.", - "input.onButtonPressed|param|body": "code to run when event is raised", - "input.onButtonPressed|param|button": "the button that needs to be pressed", "input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).", "input.onGesture|param|body": "code to run when gesture is raised", "input.onGesture|param|gesture": "the type of gesture to track, eg: Gesture.Shake", - "input.onPinPressed": "Do something when a pin is touched and released again (while also touching the GND pin).", - "input.onPinPressed|param|body": "the code to run when the pin is pressed", - "input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0", - "input.onPinReleased": "Do something when a pin is released.", - "input.onPinReleased|param|body": "the code to run when the pin is released", - "input.onPinReleased|param|name": "the pin that needs to be released, eg: TouchPin.P0", "input.onPinTouchEvent": "Do something when a pin receives an touch event (while also touching the GND pin).", "input.onPinTouchEvent|param|body": "the code to run when event is fired on pin", "input.onPinTouchEvent|param|name": "the pin, eg: TouchPin.P0", @@ -700,7 +685,7 @@ "storage.putValueInt|param|key": "the key for accesing the value", "storage.putValueInt|param|value": "value to store", "storage.remove": "Removes a key value pair from the non volatile storage", - "storage.removeKeyInt": "Deletes the key from the non volatile storage", - "storage.removeKeyInt|param|key": "the key for accesing the value", + "storage.removeNumber": "Deletes the key from the non volatile storage", + "storage.removeNumber|param|key": "the key for accesing the value", "storage.remove|param|key": "the key for accesing the value" } \ No newline at end of file diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 54b2d814..fc32f1eb 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -276,7 +276,6 @@ "basic.color|block": "%c", "basic.forever|block": "forever", "basic.pause|block": "pause (ms) %pause", - "basic.rgbw|block": "red %red|green %green|blue %blue|white %white", "basic.rgb|block": "red %red|green %green|blue %blue", "basic.setLedColor|block": "set led to %color=colorNumberPicker", "basic.showArrow|block": "show arrow %i=device_arrow", @@ -344,13 +343,9 @@ "input.isCalibratedCompass|block": "is compass calibrated", "input.isGesture|block": "is %gesture gesture", "input.lightLevel|block": "light level", - "input.loudness|block": "Loudness", "input.magneticForce|block": "magnetic force (µT)|%NAME", "input.onButtonEvent|block": "on button %NAME| %eventType=control_button_event_value_id", - "input.onButtonPressed|block": "on button|%NAME|pressed", "input.onGesture|block": "on |%NAME", - "input.onPinPressed|block": "on pin %name|pressed", - "input.onPinReleased|block": "on pin %NAME|released", "input.onPinTouchEvent|block": "on pin %name| %eventType=control_button_event_value_id", "input.pinIsPressed|block": "pin %NAME|is pressed", "input.rotation|block": "rotation (°)|%NAME", @@ -451,7 +446,7 @@ "storage.getValueInt|block": "get number from %key", "storage.putNumber|block": "Save into number %key a value of %value", "storage.putValueInt|block": "Put into %key a value of %value as Int", - "storage.removeKeyInt|block": "Clear number %key", + "storage.removeNumber|block": "Clear number %key", "storage.remove|block": "remove %key", "storage|block": "storage", "{id:category}AnalogInPin": "AnalogInPin", diff --git a/libs/core/basic.cpp b/libs/core/basic.cpp index de787576..263092f0 100644 --- a/libs/core/basic.cpp +++ b/libs/core/basic.cpp @@ -118,6 +118,7 @@ namespace basic { */ //% blockId=device_set_led_color //% block="set led to %color=colorNumberPicker" + //% color.defl=0xff0000 //% weight=10 //% group="RGB LED" void setLedColor(int color) { diff --git a/libs/core/basic.ts b/libs/core/basic.ts index b7dc96ad..8fc6b83f 100644 --- a/libs/core/basic.ts +++ b/libs/core/basic.ts @@ -82,22 +82,6 @@ namespace basic { return ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | (blue & 0xFF); } - - /** - * Converts red, green, blue channels into a RGB color - * @param red value of the red channel between 0 and 255. eg: 255 - * @param green value of the green channel between 0 and 255. eg: 255 - * @param blue value of the blue channel between 0 and 255. eg: 255 - * @param white value of the white channel between 0 and 255. eg: 0 - */ - //% weight=2 - //% blockId="core_rgbw" block="red %red|green %green|blue %blue|white %white" - //% group="RGB LED" - //% deprecated=true - export function rgbw(red: number, green: number, blue: number, white:number): number { - return ((white & 0xFF) << 24) | ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | (blue & 0xFF); - } - } /** diff --git a/libs/core/blocks-test/basic.blocks b/libs/core/blocks-test/basic.blocks index 3a15fc01..c1c8ed2f 100644 --- a/libs/core/blocks-test/basic.blocks +++ b/libs/core/blocks-test/basic.blocks @@ -1,53 +1,125 @@ - - - receivedNumber - - - - - - - 12 - - - - - IconNames.Umbrella - - - - - hi! - - - - - - - 100 - - - - - - - - - 100 - - - - - - - - - - - - - - - - + + + receivedNumber + + + + + + + 12 + + + + + + + 0 + + + + + IconNames.Umbrella + + + IconNames.Heart + + + + + hi! + + + + + + + hi! + + + + + + + 100 + + + + + + + ` + . . . . # + . . . # . + . . # . . + . # . . . + # . . . . + ` + + + + + 0xff0000 + + + + + + + 0 + + + + + 255 + + + + + 255 + + + + + 255 + + + + + + + + + 600 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/core/blocks-test/image.blocks b/libs/core/blocks-test/image.blocks index a583dc7f..3648e3a2 100644 --- a/libs/core/blocks-test/image.blocks +++ b/libs/core/blocks-test/image.blocks @@ -1,38 +1,53 @@ - - - item - - - - - - - IconNames.Heart - - - - - 0 - - - - - - - 1 - - - - - 200 - - - - - - - - - item - + + + item + + + + + item + + + 0 + + + IconNames.Yes + + + + + + + IconNames.Heart + + + + + 0 + + + + + + + item + + + + + 1 + + + + + 200 + + + + + + + + + \ No newline at end of file diff --git a/libs/core/blocks-test/input.blocks b/libs/core/blocks-test/input.blocks index dce61b60..cf58b748 100644 --- a/libs/core/blocks-test/input.blocks +++ b/libs/core/blocks-test/input.blocks @@ -1,132 +1,141 @@ - - - item - sdfsadf - - - Button.AB - - - item - - - 0 - - - Button.B - + + + item + sdfsadf + + + Button.AB + + - - - item - - - 0 - - - TouchPin.P1 - - - - - sdfsadf + + + item - - 0 - - - Dimension.Y - + + 0 + + + Button.B + - - sdfsadf - - - 0 - - - - - - sdfsadf + + item - - 0 - - + + 0 + + + TouchPin.P1 + - - sdfsadf - - - 0 - - - - - - sdfsadf + + sdfsadf - - 0 - - - Rotation.Roll - + + 0 + + + Dimension.Y + - - sdfsadf - - - 0 - - - Dimension.Z - - - - - sdfsadf + + sdfsadf - - 0 - - + + 0 + + - - AcceleratorRange.TwoG - + + sdfsadf + + + 0 + + + + + + sdfsadf + + + 0 + + + + + + sdfsadf + + + 0 + + + Rotation.Roll + + + + + sdfsadf + + + 0 + + + Dimension.Z + + + + + sdfsadf + + + 0 + + + + + + AcceleratorRange.TwoG + + + + + + + + + + + - - - + - - - + - - - + - - - - - - - - - Gesture.SixG - - - TouchPin.P2 - - - TouchPin.P2 - + + + + + Gesture.SixG + + + TouchPin.P0 + + + + + + TouchPin.P0 + + + + \ No newline at end of file diff --git a/libs/core/blocks-test/motors.blocks b/libs/core/blocks-test/motors.blocks new file mode 100644 index 00000000..28ded019 --- /dev/null +++ b/libs/core/blocks-test/motors.blocks @@ -0,0 +1,29 @@ + + + + + + + 100 + + + + + MotorCommand.Break + + + Motor.A + + + 100 + + + + + + + + + + + \ No newline at end of file diff --git a/libs/core/blocks-test/music.blocks b/libs/core/blocks-test/music.blocks index 96719219..78d455ad 100644 --- a/libs/core/blocks-test/music.blocks +++ b/libs/core/blocks-test/music.blocks @@ -1,95 +1,94 @@ - - - item - - - MusicEvent.BackgroundMelodyStarted - - - - - 175 - - - - - BeatFraction.Sixteenth - - - - - - - 147 - - - - + + + item + + + + + + + 175 + + - - BeatFraction.Sixteenth - + + BeatFraction.Sixteenth + - - item - - - 0 - - - 466 - - - - - item - - - 0 - - - BeatFraction.Sixteenth - + + + + 147 + - - item - - - 0 - - - - - - - - 1242 - + + + + BeatFraction.Sixteenth + - - - - 5 - - - + + item + + + 0 + + + 466 + + + + + item + + + 0 + + + BeatFraction.Sixteenth + + + + + item + + + 0 + + + + + + + + 1242 + + + + + + + 5 + + + + + + + + + + + - - - + - - - + - - - - - - - + + + \ No newline at end of file diff --git a/libs/core/blocks-test/serial.blocks b/libs/core/blocks-test/serial.blocks index f1edf86c..827a64d2 100644 --- a/libs/core/blocks-test/serial.blocks +++ b/libs/core/blocks-test/serial.blocks @@ -59,8 +59,8 @@ - SerialPin.P12 - SerialPin.P13 + SerialPin.C16 + SerialPin.C17 BaudRate.BaudRate28800 diff --git a/libs/core/blocks-test/test.blocks b/libs/core/blocks-test/test.blocks index f175a9a5..d3d9ba59 100644 --- a/libs/core/blocks-test/test.blocks +++ b/libs/core/blocks-test/test.blocks @@ -1 +1,684 @@ -booltestmyImagestrtest123` # . . # . # . . # . . # . . . . # # . . . . . . . `IconNames.Heart500IconNames.HeartmyImage0myImage13strtest0Delimiters.Hashstrtest0TouchPin.P212545DisplayMode.GreyscaleAnalogPin.P21023AnalogPin.P2DigitalPin.P10DigitalPin.P1AnalogPin.P21234001023Rotation.Roll0Dimension.Y4AnalogPin.P2180Dimension.ZAnalogPin.P21500220BeatFraction.Sixteenth659BeatFraction.DoubleMelodyOptions.ForeverInBackgroundMelodies.RingtoneGesture.TiltLeft1EventBusValue.MICROBIT_PIN_EVT_PULSE_HI264booltest0Button.Bbooltest0TouchPin.P2booltest034Button.AB1BeatFraction.Sixteenth235255255440TRUE4EventBusSource.MICROBIT_ID_IO_P0EventBusValue.MES_ALERT_EVT_ALARM1TouchPin.P2AcceleratorRange.EightGDelimiters.ColonSerialPin.P0SerialPin.P1BaudRate.BaudRate19200DigitalPin.P1PulseValue.LowNumberFormat.UInt8BE00FALSE00DigitalPin.P0PinEventType.Touch1000000AnalogPin.P2DigitalPin.P2PinPullMode.PullDown83DigitalPin.P1DigitalPin.P1DigitalPin.P1MusicEvent.BackgroundMelodyNotePlayed123123123120x0EventBusSource.MICROBIT_ID_IO_P1EventBusValue.MES_ALERT_EVT_ALARM2 \ No newline at end of file + + + booltest + myImage + strtest + + + + + + + 123 + + + + + + ` + # . . # . + # . . # . + . # . . . + . # # . . + . . . . . + ` + + + IconNames.Heart + + + + + 500 + + + + + + + IconNames.Heart + + + myImage + + + 0 + + + ` + . . . . . + . . . . . + . . . . . + . . . . . + . . . . . + ` + + + + + + + myImage + + + + + 0 + + + + + + + myImage + + + + + 1 + + + + + + 3 + + + + + strtest + + + 0 + + + + + Delimiters.Hash + + + + + + + strtest + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + 2 + + + + + + + 5 + + + + + 45 + + + + + DisplayMode.Greyscale + + + AnalogPin.P2 + + + + 1023 + + + AnalogPin.P2 + + + + + DigitalPin.P1 + + + + 0 + + + DigitalPin.P1 + + + + + AnalogPin.P2 + + + 1234 + + + + + 0 + + + + + + 0 + + + + + + 1023 + + + Rotation.Roll + + + + + 0 + + + Dimension.Y + + + + + 4 + + + + + + + + AnalogPin.P2 + + + + 180 + + + Dimension.Z + + + + + AnalogPin.P2 + + + 1500 + + + + + + + + 220 + + + + + BeatFraction.Sixteenth + + + + + + + 659 + + + + + + + BeatFraction.Double + + + + + + + + + + + + + + + + + + + + + + + + + + + Gesture.TiltLeft + + + + + + 1 + + + EventBusValue.MICROBIT_PIN_EVT_PULSE_HI + + + + + + 2 + + + + + + + + + 64 + + + + + + + + + + + + + + + 4 + + + + + + + + EventBusSource.MICROBIT_ID_IO_P0 + + + + + EventBusValue.MES_ALERT_EVT_ALARM1 + + + + + + + + + + + booltest + + + 0 + + + Button.B + + + + + booltest + + + 0 + + + TouchPin.P2 + + + + + booltest + + + 0 + + + + + + 3 + + + + + + 4 + + + + + + + + + + + + + + + Delimiters.Colon + + + + + SerialPin.P0 + SerialPin.P1 + BaudRate.BaudRate19200 + + + + + + + + Button.AB + + + + + + + + + 1 + + + BeatFraction.Sixteenth + + + + + + 2 + + + + + + + + 3 + + + + + + + 5 + + + + + + 255 + + + + + + + + + 255 + + + 440 + + + + + + + + + TRUE + + + + + + + + + + + + + + + + + + + + + + + + DigitalPin.P1 + PulseValue.Low + + + NumberFormat.UInt8BE + + + 0 + + + + + 0 + + + + + FALSE + + + + + + + 0 + + + + + 0 + + + + + DigitalPin.P0 + PinEventType.Touch + + + + + 1000000 + + + + + AnalogPin.P2 + + + DigitalPin.P2 + PinPullMode.PullDown + + + + + 8 + + + + + 3 + + + + + DigitalPin.P1 + DigitalPin.P1 + DigitalPin.P1 + + + + + + + + + + + + + + + + + + + + + + MusicEvent.BackgroundMelodyNotePlayed + + + + + 123 + + + + + + + + 12312312 + + + + + + + + + + + + + + + 0 + + + + + + + x + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + EventBusSource.MICROBIT_ID_IO_P1 + + + + + EventBusValue.MES_ALERT_EVT_ALARM2 + + + + \ No newline at end of file diff --git a/libs/core/game.ts b/libs/core/game.ts index 41038ce7..6da731d0 100644 --- a/libs/core/game.ts +++ b/libs/core/game.ts @@ -323,9 +323,9 @@ namespace game { } function unplugEvents(): void { - input.onButtonPressed(Button.A, () => { }); - input.onButtonPressed(Button.B, () => { }); - input.onButtonPressed(Button.AB, () => { + 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 5059d8ed..de4873c5 100644 --- a/libs/core/input.cpp +++ b/libs/core/input.cpp @@ -190,21 +190,6 @@ namespace input { registerWithDal((int)button, eventType, body); } - - /** - * Do something when a button (A, B or both A+B) is pushed down and released again. - * @param button the button that needs to be pressed - * @param body code to run when event is raised - */ - //% help=input/on-button-pressed weight=85 blockGap=16 - //% blockId=device_button_event block="on button|%NAME|pressed" - //% parts="buttonpair" - //% deprecated=true - //% group="Events" - void onButtonPressed(Button button, Action body) { - registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body); - } - /** * Do something when when a gesture is done (like shaking the micro:bit). * @param gesture the type of gesture to track, eg: Gesture.Shake @@ -240,7 +225,6 @@ namespace input { return uBit.accelerometer.getGesture() == gi; } - /** * Do something when a pin receives an touch event (while also touching the GND pin). * @param name the pin, eg: TouchPin.P0 @@ -258,43 +242,6 @@ namespace input { registerWithDal((int)name, eventType, body); } - /** - * Do something when a pin is touched and released again (while also touching the GND pin). - * @param name the pin that needs to be pressed, eg: TouchPin.P0 - * @param body the code to run when the pin is pressed - */ - //% help=input/on-pin-pressed weight=83 blockGap=16 - //% blockId=device_pin_event block="on pin %name|pressed" - //% group="Events" - //% deprecated=true - void onPinPressed(TouchPin name, Action body) { - auto pin = getPin((int)name); - if (!pin) return; - - // Forces the PIN to switch to makey-makey style detection. - pin->isTouched(); - registerWithDal((int)name, MICROBIT_BUTTON_EVT_CLICK, body); - } - - /** - * Do something when a pin is released. - * @param name the pin that needs to be released, eg: TouchPin.P0 - * @param body the code to run when the pin is released - */ - //% help=input/on-pin-released weight=6 blockGap=16 - //% blockId=device_pin_released block="on pin %NAME|released" - //% advanced=true - //% group="Events" - //% deprecated=true - void onPinReleased(TouchPin name, Action body) { - auto pin = getPin((int)name); - if (!pin) return; - - // Forces the PIN to switch to makey-makey style detection. - pin->isTouched(); - registerWithDal((int)name, MICROBIT_BUTTON_EVT_UP, body); - } - /** * Get the button state (pressed or not) for ``A`` and ``B``. * @param button the button to query the request, eg: Button.A diff --git a/libs/core/microphone.ts b/libs/core/microphone.ts index 0305e535..8e2ec8eb 100644 --- a/libs/core/microphone.ts +++ b/libs/core/microphone.ts @@ -2,26 +2,26 @@ * Events and data from sensors */ //% color=#C90072 weight=99 -namespace input { +// namespace input { /** * gets the level of loudness from 0 (silent) to 255 (loud) */ //% blockId="loudness" //% block="Loudness" //% deprecated=true - export function loudness(): number { - let value = 0 - let max = pins.analogReadPin(AnalogPin.MIC) - let min = max - for (let index = 0; index < 32; index++) { - value = pins.analogReadPin(AnalogPin.MIC) - if (value > max) { - max = value - } else if (value < min) { - min = value - } - } - value = Math.floor((max - min) / 4) - return value - } -} + // export function loudness(): number { + // let value = 0 + // let max = pins.analogReadPin(AnalogPin.MIC) + // let min = max + // for (let index = 0; index < 32; index++) { + // value = pins.analogReadPin(AnalogPin.MIC) + // if (value > max) { + // max = value + // } else if (value < min) { + // min = value + // } + // } + // value = Math.floor((max - min) / 4) + // return value + // } +// } diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index a7d9b341..7346f7a2 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -217,9 +217,10 @@ declare namespace basic { */ //% blockId=device_set_led_color //% block="set led to %color=colorNumberPicker" + //% //% weight=10 - //% group="RGB LED" shim=basic::setLedColor - function setLedColor(color: int32): void; + //% group="RGB LED" color.defl=0xff0000 shim=basic::setLedColor + function setLedColor(color?: int32): void; /** * Sets the color on the build-in LED. Set to 0 to turn off. @@ -248,18 +249,6 @@ declare namespace input { //% group="Events" shim=input::onButtonEvent function onButtonEvent(button: Button, eventType: int32, body: () => void): void; - /** - * Do something when a button (A, B or both A+B) is pushed down and released again. - * @param button the button that needs to be pressed - * @param body code to run when event is raised - */ - //% help=input/on-button-pressed weight=85 blockGap=16 - //% blockId=device_button_event block="on button|%NAME|pressed" - //% parts="buttonpair" - //% deprecated=true - //% group="Events" shim=input::onButtonPressed - function onButtonPressed(button: Button, body: () => void): void; - /** * Do something when when a gesture is done (like shaking the micro:bit). * @param gesture the type of gesture to track, eg: Gesture.Shake @@ -293,29 +282,6 @@ declare namespace input { //% group="Events" shim=input::onPinTouchEvent function onPinTouchEvent(name: TouchPin, eventType: int32, body: () => void): void; - /** - * Do something when a pin is touched and released again (while also touching the GND pin). - * @param name the pin that needs to be pressed, eg: TouchPin.P0 - * @param body the code to run when the pin is pressed - */ - //% help=input/on-pin-pressed weight=83 blockGap=16 - //% blockId=device_pin_event block="on pin %name|pressed" - //% group="Events" - //% deprecated=true shim=input::onPinPressed - function onPinPressed(name: TouchPin, body: () => void): void; - - /** - * Do something when a pin is released. - * @param name the pin that needs to be released, eg: TouchPin.P0 - * @param body the code to run when the pin is released - */ - //% help=input/on-pin-released weight=6 blockGap=16 - //% blockId=device_pin_released block="on pin %NAME|released" - //% advanced=true - //% group="Events" - //% deprecated=true shim=input::onPinReleased - function onPinReleased(name: TouchPin, body: () => void): void; - /** * Get the button state (pressed or not) for ``A`` and ``B``. * @param button the button to query the request, eg: Button.A diff --git a/libs/core/storage.ts b/libs/core/storage.ts index 865ceb64..a847ecf6 100644 --- a/libs/core/storage.ts +++ b/libs/core/storage.ts @@ -60,7 +60,7 @@ namespace storage { //% block="Clear number %key" //% blockId=storage_remove_key_int //% group="Remove" - export function removeKeyInt(key: StorageSlots) : void { + export function removeNumber(key: StorageSlots) : void { remove(storagesInt[key]); } diff --git a/libs/radio-broadcast/docs/reference/radio/on-received-message.md b/libs/radio-broadcast/docs/reference/radio/on-received-message.md index 8946d0fd..fc6cbc0c 100644 --- a/libs/radio-broadcast/docs/reference/radio/on-received-message.md +++ b/libs/radio-broadcast/docs/reference/radio/on-received-message.md @@ -22,10 +22,10 @@ enum RadioMessage { heart, skull } -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { radio.sendMessage(RadioMessage.heart) }) -input.onButtonPressed(Button.B, function () { +input.onButtonEvent(Button.B, ButtonEvent.Click, function () { radio.sendMessage(RadioMessage.skull) }) radio.onReceivedMessage(RadioMessage.heart, function () { diff --git a/libs/radio-broadcast/docs/reference/radio/send-message.md b/libs/radio-broadcast/docs/reference/radio/send-message.md index e8dd9619..01058f11 100644 --- a/libs/radio-broadcast/docs/reference/radio/send-message.md +++ b/libs/radio-broadcast/docs/reference/radio/send-message.md @@ -20,10 +20,10 @@ enum RadioMessage { heart, skull } -input.onButtonPressed(Button.A, function () { +input.onButtonEvent(Button.A, ButtonEvent.Click, function () { radio.sendMessage(RadioMessage.heart) }) -input.onButtonPressed(Button.B, function () { +input.onButtonEvent(Button.B, ButtonEvent.Click, function () { radio.sendMessage(RadioMessage.skull) }) radio.onReceivedMessage(RadioMessage.heart, function () { diff --git a/package-lock.json b/package-lock.json index bfbab220..2a566283 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "pxt-common-packages": "9.0.1", - "pxt-core": "7.0.12" + "pxt-core": "7.0.14" }, "devDependencies": { "@types/marked": "0.3.0", @@ -5282,9 +5282,9 @@ } }, "node_modules/pxt-core": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-7.0.12.tgz", - "integrity": "sha512-i7caqFdwTB4Lt5yaGwCDmb+3HiBp0HIB2If0zIt7MQ9RV3vBxY0vtsd+BRoiYLPnX3vXAXQPycJgVdTntntNrw==", + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-7.0.14.tgz", + "integrity": "sha512-mLdaBm69j2AnxqQCDa7D54RyiQJMgZAiPyz/TMAmc7J0LgplJhxCqUsz6lXBur8kk4QqkS/i2/MAWIURqvuJBw==", "dependencies": { "@microsoft/immersive-reader-sdk": "1.1.0", "applicationinsights-js": "^1.0.20", @@ -10912,9 +10912,9 @@ } }, "pxt-core": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-7.0.12.tgz", - "integrity": "sha512-i7caqFdwTB4Lt5yaGwCDmb+3HiBp0HIB2If0zIt7MQ9RV3vBxY0vtsd+BRoiYLPnX3vXAXQPycJgVdTntntNrw==", + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-7.0.14.tgz", + "integrity": "sha512-mLdaBm69j2AnxqQCDa7D54RyiQJMgZAiPyz/TMAmc7J0LgplJhxCqUsz6lXBur8kk4QqkS/i2/MAWIURqvuJBw==", "requires": { "@microsoft/immersive-reader-sdk": "1.1.0", "applicationinsights-js": "^1.0.20", diff --git a/pxtarget.json b/pxtarget.json index 02ef03d3..f952b8c7 100644 --- a/pxtarget.json +++ b/pxtarget.json @@ -97,7 +97,22 @@ "map": { "DisplayMode\\s*\\.\\s*BackAndWhite": "DisplayMode.BlackAndWhite" } - }] + }], + "0.0.0 - 4.0.20": [ + { + "type": "api", + "map": { + "basic\\s*\\.\\s*showArrow\\s*\\(": "basic.showIcon(", + "images\\s*\\.\\s*arrowImage\\s*\\(": "images.iconImage(", + "ArrowNames\\s*\\.\\s*": "IconNames.Arrow", + "input\\s*\\.\\s*onButtonPressed\\s*\\(\\s*(.*?),": "input.onButtonEvent($1, ButtonEvent.Click,", + "input\\s*\\.\\s*onPinPressed\\s*\\(\\s*(.*?),": "input.onPinTouchEvent($1, ButtonEvent.Down,", + "input\\s*\\.\\s*onPinReleased\\s*\\(\\s*(.*?),": "input.onPinTouchEvent($1, ButtonEvent.Up,", + "input\\s*\\.\\s*loudness\\s*\\(": "input.soundLevel(", + "basic\\s*\\.\\s*rgbw\\s*\\(\\s*(.*?),\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*\\)": "basic.rgb($1, $2, $3)" + } + } + ] }, "hidSelectors": [{ "usagePage": "0xFF00", diff --git a/sim/state/buttonpair.ts b/sim/state/buttonpair.ts index 25992d5d..298e7044 100644 --- a/sim/state/buttonpair.ts +++ b/sim/state/buttonpair.ts @@ -8,16 +8,6 @@ namespace pxsim.input { pxtcore.registerWithDal(button, buttonEvent, handler); } - // Deprecated - export function onButtonPressed(button: number, handler: RefAction): void { - let b = board().buttonPairState; - if (button == b.props.ID_BUTTON_AB && !b.usesButtonAB) { - b.usesButtonAB = true; - runtime.queueDisplayUpdate(); - } - pxtcore.registerWithDal(button, DAL.MICROBIT_BUTTON_EVT_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 32d33e24..364fd3ec 100644 --- a/sim/state/edgeconnector.ts +++ b/sim/state/edgeconnector.ts @@ -7,24 +7,6 @@ namespace pxsim.input { pxtcore.registerWithDal(pin.id, pinEvent, handler); } - // Deprecated - export function onPinPressed(pinId: number, handler: RefAction) { - let pin = getPin(pinId); - if (!pin) return; - pin.isTouched(); - runtime.queueDisplayUpdate(); - pxtcore.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_CLICK, handler); - } - - // Deprecated - export function onPinReleased(pinId: number, handler: RefAction) { - let pin = getPin(pinId); - if (!pin) return; - pin.isTouched(); - runtime.queueDisplayUpdate(); - pxtcore.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_UP, handler); - } - export function pinIsPressed(pinId: number): boolean { let pin = getPin(pinId); if (!pin) return false; diff --git a/tests/hat-game.ts b/tests/hat-game.ts index 751113f2..6fbb74bf 100644 --- a/tests/hat-game.ts +++ b/tests/hat-game.ts @@ -7,7 +7,7 @@ let level: number let swapSpeed: number initializeGame() -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (ballRevealing) { index = index + 1 if (index > 2) { @@ -16,7 +16,7 @@ input.onButtonPressed(Button.A, () => { basic.showString(cupSelect[index], 150) } }) -input.onButtonPressed(Button.B, () => { +input.onButtonEvent(Button.B, ButtonEvent.Click, () => { if (ballRevealing) { ballRevealing = false if (correctBall == index) { diff --git a/tests/meteorite.ts b/tests/meteorite.ts index 297da4b4..a0ecd0d8 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.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { if (oneX > 0) { led.unplot(oneX, oneY) led.unplot(twoX, twoY) @@ -28,7 +28,7 @@ input.onButtonPressed(Button.A, () => { led.plot(twoX, twoY) } }) -input.onButtonPressed(Button.B, () => { +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 196150c2..4c7c400b 100644 --- a/tests/pac-man-runaway.ts +++ b/tests/pac-man-runaway.ts @@ -107,12 +107,12 @@ basic.forever(() => { basic.pause(500) } }) -input.onButtonPressed(Button.A, () => { +input.onButtonEvent(Button.A, ButtonEvent.Click, () => { let temp = Math.abs(person.dirX) * (-1) person.dirX = Math.abs(person.dirY) * (-1) person.dirY = temp }) -input.onButtonPressed(Button.B, () => { +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 3960be0b..7edd3e1e 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.onButtonPressed(Button.A, () => { + input.onButtonEvent(Button.A, ButtonEvent.Click, () => { AWasPressed = true }) - input.onButtonPressed(Button.B, () => { + input.onButtonEvent(Button.B, ButtonEvent.Click, () => { BWasPressed = true }) - input.onButtonPressed(Button.AB, () => { + 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 204b59f2..1699b33c 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.onButtonPressed(Button.A, () => { + input.onButtonEvent(Button.A, ButtonEvent.Click, () => { AWasPressed = true }) - input.onButtonPressed(Button.B, () => { + input.onButtonEvent(Button.B, ButtonEvent.Click, () => { BWasPressed = true }) - input.onButtonPressed(Button.AB, () => { + input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { ABWasPressed = true }) input.onShake(() => { diff --git a/tests/wg-operation.ts b/tests/wg-operation.ts index c43532ab..75eae609 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.onButtonPressed(Button.A, () => { + input.onButtonEvent(Button.A, ButtonEvent.Click, () => { aWasPressed = true }) bWasPressed = false - input.onButtonPressed(Button.B, () => { + 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 d03df848..c60e6f93 100644 --- a/tests/wg-user-confidance.ts +++ b/tests/wg-user-confidance.ts @@ -476,10 +476,10 @@ function testTiltZ() { } function startIOMonitor() { - input.onButtonPressed(Button.A, () => { + input.onButtonEvent(Button.A, ButtonEvent.Click, () => { AWasPressed = true }) - input.onButtonPressed(Button.B, () => { + input.onButtonEvent(Button.B, ButtonEvent.Click, () => { BWasPressed = true }) input.onShake(() => {