From 77ed2ccfb110f250aa5bc4210f1cc3ef8ef3b49a Mon Sep 17 00:00:00 2001 From: Juri Wolf Date: Wed, 11 Jan 2023 18:51:27 +0100 Subject: [PATCH] V4 updates (#210) * update pxt.json files * Fix button event enums fixes https://github.com/microsoft/pxt-calliope/issues/206 * Fix Safari CSS Rule for iOS app fixes https://github.com/microsoft/pxt-calliope/issues/205 * aprove preffered repos should fix https://github.com/microsoft/pxt-calliope/issues/167 --- docs/about.md | 8 ++-- docs/blocks/logic/boolean.md | 2 +- docs/blocks/logic/if.md | 2 +- docs/blocks/loops/for.md | 2 +- docs/blocks/loops/while.md | 2 +- docs/blocks/on-start.md | 2 +- docs/blocks/variables/var.md | 2 +- docs/device/crocodile-clips.md | 2 +- docs/device/data-analysis/led-plotting.md | 2 +- docs/device/reactive.md | 10 ++--- docs/device/serial.md | 2 +- docs/device/simulator.md | 10 ++--- docs/examples/gameofLife.md | 4 +- docs/projects/coin-flipper.md | 8 ++-- docs/projects/love-meter.md | 6 +-- docs/projects/mini-chat.md | 4 +- docs/projects/name-badge.md | 8 ++-- docs/projects/robot-unicorn.md | 2 +- docs/projects/rotary-dial-radio.md | 2 +- docs/projects/smiley-buttons.md | 8 ++-- docs/projects/snap-the-dot.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/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/is-paused.md | 2 +- docs/reference/game/score.md | 2 +- docs/tutorials/getting-started.md | 4 +- docs/tutorials/hour-of-code/hey-microbit.md | 6 +-- docs/types/buffer/using-buffers.md | 8 ++-- libs/blocksprj/pxt.json | 2 +- libs/bluetooth/pxt.json | 8 ++-- libs/bluetoothprj/pxt.json | 2 +- libs/core/enums.d.ts | 12 +----- libs/core/game.ts | 6 +-- libs/core/input.cpp | 12 +----- libs/core/input.ts | 22 +++++++++- libs/core/pxt.json | 9 ++-- libs/devices/pxt.json | 12 +++--- libs/microphone/pxt.json | 16 +++++--- .../reference/radio/on-received-message.md | 4 +- .../docs/reference/radio/send-message.md | 4 +- libs/radio-broadcast/pxt.json | 9 ++++ libs/radio/pxt.json | 16 +++++++- libs/servo/pxt.json | 14 ++++--- libs/tsprj/pxt.json | 2 +- pxtarget.json | 14 +++++-- targetconfig.json | 41 +++++++++++++------ 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 +- theme/style.less | 6 +++ 62 files changed, 223 insertions(+), 162 deletions(-) diff --git a/docs/about.md b/docs/about.md index 8f1673dc..aaa4ddb6 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { basic.showString("Hi!"); }) ``` ```typescript -input.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { led.stopAnimation(); basic.showLeds(` . . . . . @@ -63,7 +63,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Down, () => { # . . . # . # # # .`); }); -input.onButtonEvent(Button.B, ButtonEvent.Down, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Down), () => { led.stopAnimation(); basic.showLeds(` . # . # . diff --git a/docs/blocks/logic/boolean.md b/docs/blocks/logic/boolean.md index 3323994e..7c7673f4 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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 0e33c943..afa0c058 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { if(input.lightLevel()<100){ led.setBrightness(255); } diff --git a/docs/blocks/loops/for.md b/docs/blocks/loops/for.md index 68919471..424c8f17 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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 60e886fe..578d76e4 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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 c0f746fb..9d6ce980 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { basic.showString("Hello!") }) led.setBrightness(50) diff --git a/docs/blocks/variables/var.md b/docs/blocks/variables/var.md index 20d3b6cd..bc2b3801 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { counter = counter + 1; basic.showNumber(counter); }); diff --git a/docs/device/crocodile-clips.md b/docs/device/crocodile-clips.md index 4e7d28a8..12ba0368 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.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { +input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(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 d0914ec3..71eaefaa 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.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(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 b5a9c6b2..1e2242cc 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { count = count + 1 }) @@ -165,7 +165,7 @@ basic.forever(() => { basic.showNumber(count) }) -input.onButtonEvent(Button.B, ButtonEvent.Down, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Down), () => { count = 0 }) ``` diff --git a/docs/device/serial.md b/docs/device/serial.md index 11b6ff48..1eec75ce 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { serial.writeLine("A pressed") }) ``` diff --git a/docs/device/simulator.md b/docs/device/simulator.md index bbd74ca2..c4d399e0 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { basic.showString("A"); }); -input.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { basic.showString("B"); }); -input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => { +input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(ButtonEvent.Click), () => { basic.showString("0"); }); -input.onPinTouchEvent(TouchPin.P1, ButtonEvent.Click, () => { +input.onPinTouchEvent(TouchPin.P1, input.buttonEventValue(ButtonEvent.Click), () => { basic.showString("1"); }); -input.onPinTouchEvent(TouchPin.P2, ButtonEvent.Click, () => { +input.onPinTouchEvent(TouchPin.P2, input.buttonEventValue(ButtonEvent.Click), () => { basic.showString("2"); }); input.temperature() diff --git a/docs/examples/gameofLife.md b/docs/examples/gameofLife.md index 93a6b049..e059943f 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { gameOfLife(); show(); }) //Use button B for reseting to random initial seed state -input.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { reset(); show(); }) diff --git a/docs/projects/coin-flipper.md b/docs/projects/coin-flipper.md index 5a9e1f6d..7c847998 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { if (Math.randomBoolean()) { } else { } @@ -34,7 +34,7 @@ input.onButtonEvent(Button.A, ButtonEvent.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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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 fb3dff23..59b66cd3 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.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { +input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(ButtonEvent.Down), () => { }); ``` @@ -20,7 +20,7 @@ input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from `0` to `100` when pin **0** is pressed. ```blocks -input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { +input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(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.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => { +input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(ButtonEvent.Down), () => { basic.showNumber(randint(0, 100)); }); ``` diff --git a/docs/projects/mini-chat.md b/docs/projects/mini-chat.md index 9d48507c..0e1ca473 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { radio.sendString("Yo"); }); radio.onReceivedString(function (receivedString) { diff --git a/docs/projects/name-badge.md b/docs/projects/name-badge.md index cebbd7ef..04ce1a9d 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.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), function () { }) ``` @@ -23,7 +23,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, function () { From the ``||basic:Basic||`` Toolbox drawer drag a ``||basic:show string||`` block into the ``||input:on button A pressed||`` block. ```blocks -input.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), function () { basic.showString("Hello!") }) ``` @@ -33,7 +33,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, function () { In the ``||basic:show string||`` block, type your name. ```blocks -input.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), function () { basic.showString("My Name") }) ``` @@ -43,7 +43,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, function () { Go to the simulator and test your name badge by pressing button **A**. ```sim -input.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), function () { basic.showString("My Name") }) ``` diff --git a/docs/projects/robot-unicorn.md b/docs/projects/robot-unicorn.md index d70af286..cd697d9f 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.onButtonEvent(Button.AB, ButtonEvent.Down, function () { +input.onButtonEvent(Button.AB, input.buttonEventValue(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 15bf3ea4..325cc393 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.onButtonEvent(Button.A, ButtonEvent.Down, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), function () { basic.showNumber(pulseCount) pulseCount = 0 }) diff --git a/docs/projects/smiley-buttons.md b/docs/projects/smiley-buttons.md index 1cacea48..765224a4 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { }); ``` @@ -21,7 +21,7 @@ input.onButtonEvent(Button.A, ButtonEvent.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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { basic.showLeds(` # # . # # # # . # # @@ -37,7 +37,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, () => { Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed. ```blocks -input.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { basic.showLeds(` # # . # # # # . # # @@ -53,7 +53,7 @@ input.onButtonEvent(Button.B, ButtonEvent.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.onButtonEvent(Button.AB, ButtonEvent.Click, () => { +input.onButtonEvent(Button.AB, input.buttonEventValue(ButtonEvent.Click), () => { basic.showLeds(` . . . . . # . # . . diff --git a/docs/projects/snap-the-dot.md b/docs/projects/snap-the-dot.md index 3a628e45..5856d946 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.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), function () { if (sprite.get(LedSpriteProperty.X) == 2) { game.addScore(1) } else { diff --git a/docs/reference/bluetooth/stop-advertising.md b/docs/reference/bluetooth/stop-advertising.md index 53b86468..987cd602 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { bluetooth.stopAdvertising(); }) ``` diff --git a/docs/reference/bluetooth/uart-write-line.md b/docs/reference/bluetooth/uart-write-line.md index 405caddd..40494fe7 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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 ab38750f..47291dcd 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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 2851ed8b..13439a17 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { num++; }) ``` @@ -42,7 +42,7 @@ let num = 0 basic.forever(() => { basic.showNumber(num) }) -input.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { num++; }) ``` diff --git a/docs/reference/control/reset.md b/docs/reference/control/reset.md index c7743adf..2ca53f57 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { item = item + 1; basic.showNumber(item); }); -input.onButtonEvent(Button.B, ButtonEvent.Down, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Down), () => { control.reset(); }); ``` diff --git a/docs/reference/game/add-score.md b/docs/reference/game/add-score.md index 845a4eef..0791642e 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.onButtonEvent(Button.B, ButtonEvent.Down, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Down), () => { basic.showNumber(game.score()) game.setScore(0) }) -input.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { game.addScore(1) }) ``` diff --git a/docs/reference/game/change-score-by.md b/docs/reference/game/change-score-by.md index 2cc54d5a..5d8cc6e9 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { game.addScore(1) }) game.startCountdown(10000) diff --git a/docs/reference/game/clear.md b/docs/reference/game/clear.md index f9c86ca4..8a14561a 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { img.clear() img.showImage(0) }) diff --git a/docs/reference/game/game-over.md b/docs/reference/game/game-over.md index 9347c3e2..5a5e5b0a 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { basic.showString("YOU WIN!"); }); -input.onButtonEvent(Button.B, ButtonEvent.Down, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(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 65a9e3cb..1e8f0b1a 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.onButtonEvent(Button.B, ButtonEvent.Down, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(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 6de3ddf2..811e691c 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.onButtonEvent(Button.B, ButtonEvent.Down, function () { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Down), function () { if (game.isPaused()) { game.resume() } diff --git a/docs/reference/game/score.md b/docs/reference/game/score.md index 123fc8e7..c993a76b 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.onButtonEvent(Button.A, ButtonEvent.Down, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { game.addScore(1); basic.pause(500); basic.showNumber(game.score()); diff --git a/docs/tutorials/getting-started.md b/docs/tutorials/getting-started.md index 3007a6de..0b3f465a 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(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 353b2177..794f1237 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { basic.showString("My Name") }); ``` @@ -23,7 +23,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { basic.showString("How are you?") basic.showString("....."); }) @@ -34,7 +34,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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 5e112b7e..c3b8a84b 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(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.onButtonEvent(Button.A, ButtonEvent.Click, () => { dataReady = true; }) -input.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { if (dataReady) { serial.writeLine("Transferring file: DARKNESS, Length: " + darkness.length + " bytes..."); serial.writeBuffer(darkness) diff --git a/libs/blocksprj/pxt.json b/libs/blocksprj/pxt.json index 4e9dbf9f..a88d98fc 100644 --- a/libs/blocksprj/pxt.json +++ b/libs/blocksprj/pxt.json @@ -1,9 +1,9 @@ { "name": "{0} block", + "description": "", "dependencies": { "core": "file:../core" }, - "description": "", "files": [ "main.blocks", "main.ts", diff --git a/libs/bluetooth/pxt.json b/libs/bluetooth/pxt.json index 1cac2468..c63bd13e 100644 --- a/libs/bluetooth/pxt.json +++ b/libs/bluetooth/pxt.json @@ -1,6 +1,9 @@ { "name": "bluetooth", "description": "Bluetooth services", + "dependencies": { + "core": "file:../core" + }, "files": [ "README.md", "enums.d.ts", @@ -10,13 +13,10 @@ "BLEHF2Service.h", "BLEHF2Service.cpp" ], + "public": true, "weight": 10, "searchOnly": true, "icon": "./static/packages/bluetooth/icon.png", - "public": true, - "dependencies": { - "core": "file:../core" - }, "yotta": { "config": { "microbit-dal": { diff --git a/libs/bluetoothprj/pxt.json b/libs/bluetoothprj/pxt.json index c9a514b2..e2d43c48 100644 --- a/libs/bluetoothprj/pxt.json +++ b/libs/bluetoothprj/pxt.json @@ -1,10 +1,10 @@ { "name": "{0} block", + "description": "", "dependencies": { "core": "file:../core", "bluetooth": "file:../bluetooth" }, - "description": "", "files": [ "main.blocks", "main.ts", diff --git a/libs/core/enums.d.ts b/libs/core/enums.d.ts index 7dbbd022..4dca7607 100644 --- a/libs/core/enums.d.ts +++ b/libs/core/enums.d.ts @@ -39,21 +39,11 @@ declare namespace basic { } - declare const enum ButtonEvent { - //% blockIdentity="input.buttonEventValueId" - //% block="pressed down" + declare const enum ButtonEvents { Down = 1, // MICROBIT_BUTTON_EVT_DOWN - //% blockIdentity="input.buttonEventValueId" - //% block="released up" Up = 2, // MICROBIT_BUTTON_EVT_UP - //% blockIdentity="input.buttonEventValueId" - //% block="clicked" Click = 3, // MICROBIT_BUTTON_EVT_CLICK - //% blockIdentity="input.buttonEventValueId" - //% block="long clicked" LongClick = 4, // MICROBIT_BUTTON_EVT_LONG_CLICK - //% blockIdentity="input.buttonEventValueId" - //% block="hold" Hold = 5, // MICROBIT_BUTTON_EVT_HOLD } diff --git a/libs/core/game.ts b/libs/core/game.ts index 6da731d0..d0258ef4 100644 --- a/libs/core/game.ts +++ b/libs/core/game.ts @@ -323,9 +323,9 @@ namespace game { } function unplugEvents(): void { - input.onButtonEvent(Button.A, ButtonEvent.Click, () => { }); - input.onButtonEvent(Button.B, ButtonEvent.Click, () => { }); - input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { + input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { }); + input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { }); + input.onButtonEvent(Button.AB, input.buttonEventValue(ButtonEvent.Click), () => { control.reset(); }); } diff --git a/libs/core/input.cpp b/libs/core/input.cpp index 71d65462..c40a6afa 100644 --- a/libs/core/input.cpp +++ b/libs/core/input.cpp @@ -7,21 +7,11 @@ enum class Button { AB = MICROBIT_ID_BUTTON_AB, }; -enum class ButtonEvent { - //% blockIdentity="input.buttonEventValueId" - //% block="pressed down" +enum class ButtonEvents { Down = MICROBIT_BUTTON_EVT_DOWN, - //% blockIdentity="input.buttonEventValueId" - //% block="released up" Up = MICROBIT_BUTTON_EVT_UP, - //% blockIdentity="input.buttonEventValueId" - //% block="clicked" Click = MICROBIT_BUTTON_EVT_CLICK, - //% blockIdentity="input.buttonEventValueId" - //% block="long clicked" LongClick = MICROBIT_BUTTON_EVT_LONG_CLICK, - //% blockIdentity="input.buttonEventValueId" - //% block="hold" Hold = MICROBIT_BUTTON_EVT_HOLD, }; diff --git a/libs/core/input.ts b/libs/core/input.ts index d7809594..8c1df6fe 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -1,3 +1,23 @@ +enum ButtonEvent { + //% blockIdentity="input.buttonEventValueId" + //% block="pressed down" + Down = ButtonEvents.Down, + //% blockIdentity="input.buttonEventValueId" + //% block="released up" + Up = ButtonEvents.Up, + //% blockIdentity="input.buttonEventValueId" + //% block="clicked" + Click = ButtonEvents.Click, + //% blockIdentity="input.buttonEventValueId" + //% block="long clicked" + LongClick = ButtonEvents.LongClick, + //% blockIdentity="input.buttonEventValueId" + //% block="hold" + Hold = ButtonEvents.Hold, +}; + + + /** * Events and data from sensors */ @@ -10,7 +30,7 @@ namespace input { */ //% help=input/button-event //% weight=19 blockId="control_button_event_value" block="%id" - //% shim=TD_ID advanced=true + //% advanced=true //% group="Events" export function buttonEventValue(id: ButtonEvent): number { return id; diff --git a/libs/core/pxt.json b/libs/core/pxt.json index 59e8bfc7..5eea9479 100644 --- a/libs/core/pxt.json +++ b/libs/core/pxt.json @@ -1,7 +1,7 @@ { "name": "core", "description": "The microbit core library", - "additionalFilePath": "../../node_modules/pxt-common-packages/libs/base", + "dependencies": {}, "files": [ "README.md", "platform.h", @@ -76,7 +76,7 @@ ], "testFiles": [], "public": true, - "dependencies": {}, + "additionalFilePath": "../../node_modules/pxt-common-packages/libs/base", "dalDTS": { "compileServiceVariant": "mbcodal", "includeDirs": [ @@ -172,5 +172,6 @@ } } ] - } -} \ No newline at end of file + }, + "partial": true +} diff --git a/libs/devices/pxt.json b/libs/devices/pxt.json index 5ce0fd32..4f9245d4 100644 --- a/libs/devices/pxt.json +++ b/libs/devices/pxt.json @@ -1,6 +1,10 @@ { "name": "devices", "description": "BETA - Camera, remote control and other Bluetooth services. App required.", + "dependencies": { + "core": "file:../core", + "bluetooth": "file:../bluetooth" + }, "files": [ "README.md", "enums.d.ts", @@ -8,12 +12,8 @@ "devices.cpp", "devices.ts" ], + "public": true, "icon": "./static/packages/devices/icon.png", "hidden": true, - "public": true, - "dependencies": { - "core": "file:../core", - "bluetooth": "file:../bluetooth" - }, "installedVersion": "ljipgq" -} \ No newline at end of file +} diff --git a/libs/microphone/pxt.json b/libs/microphone/pxt.json index 0769e2fc..be21a36a 100644 --- a/libs/microphone/pxt.json +++ b/libs/microphone/pxt.json @@ -1,5 +1,9 @@ { - "additionalFilePath": "../../node_modules/pxt-common-packages/libs/microphone", + "name": "microphone", + "description": "The microphone library", + "dependencies": { + "core": "file:../core" + }, "files": [ "README.md", "microphone.cpp", @@ -7,8 +11,10 @@ "enums.d.ts", "shims.d.ts" ], - "hidden": true, - "dependencies": { - "core": "file:../core" - } + "testFiles": [ + "test.ts" + ], + "public": true, + "additionalFilePath": "../../node_modules/pxt-common-packages/libs/microphone", + "hidden": true } 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 fc6cbc0c..a2fbc979 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.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), function () { radio.sendMessage(RadioMessage.heart) }) -input.onButtonEvent(Button.B, ButtonEvent.Click, function () { +input.onButtonEvent(Button.B, input.buttonEventValue(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 01058f11..70212a0d 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.onButtonEvent(Button.A, ButtonEvent.Click, function () { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), function () { radio.sendMessage(RadioMessage.heart) }) -input.onButtonEvent(Button.B, ButtonEvent.Click, function () { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), function () { radio.sendMessage(RadioMessage.skull) }) radio.onReceivedMessage(RadioMessage.heart, function () { diff --git a/libs/radio-broadcast/pxt.json b/libs/radio-broadcast/pxt.json index b1851bb9..42abc4aa 100644 --- a/libs/radio-broadcast/pxt.json +++ b/libs/radio-broadcast/pxt.json @@ -1,4 +1,13 @@ { + "name": "radio-broadcast", + "description": "Adds new blocks for message communication in the radio category", + "dependencies": { + "core": "file:../core", + "radio": "file:../radio" + }, + "files": [ + "radio-broadcast.ts" + ], "additionalFilePath": "../../node_modules/pxt-common-packages/libs/radio-broadcast", "icon": "./static/packages/radio-broadcast/icon.png" } diff --git a/libs/radio/pxt.json b/libs/radio/pxt.json index 4b5652ad..29a65adf 100644 --- a/libs/radio/pxt.json +++ b/libs/radio/pxt.json @@ -1,4 +1,18 @@ { + "name": "radio", + "description": "The radio services", + "dependencies": { + "core": "file:../core" + }, + "files": [ + "README.md", + "shims.d.ts", + "enums.d.ts", + "radio.cpp", + "radio.ts", + "targetoverrides.ts" + ], + "public": true, "additionalFilePath": "../../node_modules/pxt-common-packages/libs/radio", "icon": "./static/packages/radio/icon.png", "yotta": { @@ -10,4 +24,4 @@ } } } -} \ No newline at end of file +} diff --git a/libs/servo/pxt.json b/libs/servo/pxt.json index e34cc07d..b5d543f2 100644 --- a/libs/servo/pxt.json +++ b/libs/servo/pxt.json @@ -1,14 +1,16 @@ { - "additionalFilePath": "../../node_modules/pxt-common-packages/libs/servo", + "name": "servo", + "description": "A micro-servo library", + "dependencies": { + "core": "file:../core" + }, "files": [ "README.md", "servo.ts", "ns.ts", "targetoverrides.ts" ], - "icon": "./static/packages/servo/icon.png", "public": true, - "dependencies": { - "core": "file:../core" - } -} \ No newline at end of file + "additionalFilePath": "../../node_modules/pxt-common-packages/libs/servo", + "icon": "./static/packages/servo/icon.png" +} diff --git a/libs/tsprj/pxt.json b/libs/tsprj/pxt.json index 79e518b7..eb8d61af 100644 --- a/libs/tsprj/pxt.json +++ b/libs/tsprj/pxt.json @@ -1,10 +1,10 @@ { "name": "{0} bit", + "description": "", "dependencies": { "core": "file:../core", "radio": "file:../radio" }, - "description": "", "files": [ "main.ts", "README.md" diff --git a/pxtarget.json b/pxtarget.json index 2bfdd815..8a10dfdf 100644 --- a/pxtarget.json +++ b/pxtarget.json @@ -105,13 +105,21 @@ "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*onButtonPressed\\s*\\(\\s*(.*?),": "input.onButtonEvent($1, input.buttonEventValue(ButtonEvent.Click),", + "input\\s*\\.\\s*onPinPressed\\s*\\(\\s*(.*?),": "input.onPinTouchEvent($1, input.buttonEventValue(ButtonEvent.Down),", + "input\\s*\\.\\s*onPinReleased\\s*\\(\\s*(.*?),": "input.onPinTouchEvent($1, input.buttonEventValue(ButtonEvent.Up),", "input\\s*\\.\\s*loudness\\s*\\(": "input.soundLevel(", "basic\\s*\\.\\s*rgbw\\s*\\(\\s*(.*?),\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*\\)": "basic.rgb($1, $2, $3)" } } + ], + "0.0.0 - 4.0.29": [ + { + "type": "api", + "map": { + "input\\s*\\.\\s*onButtonEvent\\s*\\(\\s*(.*?),\\s*ButtonEvent\\s*.\\s*(.*?),": "input.onButtonEvent($1, input.buttonEventValue(ButtonEvent.$2)," + } + } ] }, "hidSelectors": [{ diff --git a/targetconfig.json b/targetconfig.json index 9f2394ad..3abd2973 100644 --- a/targetconfig.json +++ b/targetconfig.json @@ -18,40 +18,47 @@ "KitronikLtd/pxt-kitronik-rtc", "KitronikLtd/pxt-kitronik-servo-lite", "KitronikLtd/pxt-kitronik-stopbit", + "MKleinSB/pxt-MAX7219_8x8", + "MKleinSB/pxt-OLED-SSD1306", + "MKleinSB/pxt-OLEDpaint", + "MKleinSB/pxt-callibot", + "MKleinSB/pxt-callicolor", + "MKleinSB/pxt-callicross", + "MKleinSB/pxt-callimotor", + "MKleinSB/pxt-calliope-buttons", + "MKleinSB/pxt-CO2OLED", + "MKleinSB/pxt-dht11", + "MKleinSB/pxt-esp-thingspeak", + "MKleinSB/pxt-gatorlog-calliope", + "MKleinSB/pxt-huskylens", + "MKleinSB/pxt-kitronik-zip-tile-calliope", + "MKleinSB/pxt-mpr121", + "MKleinSB/pxt-pca9685", + "MKleinSB/pxt-seeed-temperature", + "MKleinSB/pxt-serialmp3", + "MKleinSB/pxt-KY-040", "MKleinSB/ScrollText", "MKleinSB/pxt-BME680", "MKleinSB/pxt-IR-Calliope", "MKleinSB/pxt-MCP23017", - "MKleinSB/pxt-OLED-SSD1306", "MKleinSB/pxt-Seeed-Temperatursensor", "MKleinSB/pxt-automationbit-calliope", "MKleinSB/pxt-bc95", - "MKleinSB/pxt-callibot", - "MKleinSB/pxt-callicolor", - "MKleinSB/pxt-callicross", "MKleinSB/pxt-calliope-esp", "MKleinSB/pxt-calliope-oled96", "MKleinSB/pxt-columbuseye", - "MKleinSB/pxt-dht11", "MKleinSB/pxt-envirobit", - "MKleinSB/pxt-esp-thingspeak", "MKleinSB/pxt-fischertechnik-calliope", "MKleinSB/pxt-foldio", "MKleinSB/pxt-ft-fototransistor-calliope", - "MKleinSB/pxt-gatorlog-calliope", "MKleinSB/pxt-graphs", "MKleinSB/pxt-iot-environment-kit", "MKleinSB/pxt-kitronik-robotics-board-calliope", "MKleinSB/pxt-kitronik-zip-64", - "MKleinSB/pxt-kitronik-zip-tile-calliope", "MKleinSB/pxt-makerbit-motor-calliope", "MKleinSB/pxt-makerbit-touch", "MKleinSB/pxt-makerbit-ultrasonic-calliope", - "MKleinSB/pxt-mpr121", - "MKleinSB/pxt-pca9685", - "MKleinSB/pxt-seeed-temperature", "MKleinSB/pxt-serial-rb", - "MKleinSB/pxt-serialmp3", "MKleinSB/pxt-thumbjoystick-calliope", "Microsoft/pxt-bluetooth-max6675", "Microsoft/pxt-bluetooth-midi", @@ -79,10 +86,16 @@ "alankrantas/pxt-ESP8266_ThingSpeak", "assirati/pxt-inventura", "calliope-edu/CO2-Sensor-SCD40", + "calliope-edu/pxt-HM3301_Dust_Sensor", "calliope-edu/pxt-SCD30", "calliope-edu/pxt-TCS34725FN", + "calliope-edu/pxt-display", "calliope-edu/pxt-grove", + "calliope-edu/pxt-rgblcd", "calliope-edu/pxt-sunlightsensor-si1145", + "calliope-mini/pxt-SCD30", + "tinysuperlab/motionkit", + "tinysuperlab/touchkit", "cgs-matthew-pham/pxt-hitechnic-irseeker-v2", "jcubuntu/pxt-iKB1", "jdarling/pxt-pca9685", @@ -122,7 +135,9 @@ "sparkfun/pxt-gator-temp", "tinysuperlab/motionkit", "tinysuperlab/touchkit", - "vengit/pxt-sbrick" + "vengit/pxt-sbrick", + "dl1ekm/pxt-calliope-ADS1x15", + "dl1ekm/pxt-calliope-PCF85063-RTC" ], "preferredRepos": [ "calliope-edu/CO2-Sensor-SCD40", diff --git a/tests/hat-game.ts b/tests/hat-game.ts index 6fbb74bf..6d992323 100644 --- a/tests/hat-game.ts +++ b/tests/hat-game.ts @@ -7,7 +7,7 @@ let level: number let swapSpeed: number initializeGame() -input.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { if (ballRevealing) { index = index + 1 if (index > 2) { @@ -16,7 +16,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, () => { basic.showString(cupSelect[index], 150) } }) -input.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { if (ballRevealing) { ballRevealing = false if (correctBall == index) { diff --git a/tests/meteorite.ts b/tests/meteorite.ts index a0ecd0d8..97f409c2 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { if (oneX > 0) { led.unplot(oneX, oneY) led.unplot(twoX, twoY) @@ -28,7 +28,7 @@ input.onButtonEvent(Button.A, ButtonEvent.Click, () => { led.plot(twoX, twoY) } }) -input.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(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 4c7c400b..83762968 100644 --- a/tests/pac-man-runaway.ts +++ b/tests/pac-man-runaway.ts @@ -107,12 +107,12 @@ basic.forever(() => { basic.pause(500) } }) -input.onButtonEvent(Button.A, ButtonEvent.Click, () => { +input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { let temp = Math.abs(person.dirX) * (-1) person.dirX = Math.abs(person.dirY) * (-1) person.dirY = temp }) -input.onButtonEvent(Button.B, ButtonEvent.Click, () => { +input.onButtonEvent(Button.B, input.buttonEventValue(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 7edd3e1e..93c942a1 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { + input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { AWasPressed = true }) - input.onButtonEvent(Button.B, ButtonEvent.Click, () => { + input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { BWasPressed = true }) - input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { + input.onButtonEvent(Button.AB, input.buttonEventValue(ButtonEvent.Click), () => { ABWasPressed = true AWasPressed = false BWasPressed = false diff --git a/tests/wg-dr-who.ts b/tests/wg-dr-who.ts index 1699b33c..24d72dc2 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { + input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { AWasPressed = true }) - input.onButtonEvent(Button.B, ButtonEvent.Click, () => { + input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { BWasPressed = true }) - input.onButtonEvent(Button.AB, ButtonEvent.Click, () => { + input.onButtonEvent(Button.AB, input.buttonEventValue(ButtonEvent.Click), () => { ABWasPressed = true }) input.onShake(() => { diff --git a/tests/wg-operation.ts b/tests/wg-operation.ts index 75eae609..a925918b 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.onButtonEvent(Button.A, ButtonEvent.Click, () => { + input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { aWasPressed = true }) bWasPressed = false - input.onButtonEvent(Button.B, ButtonEvent.Click, () => { + input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { bWasPressed = true }) wasTweezers = false diff --git a/tests/wg-user-confidance.ts b/tests/wg-user-confidance.ts index c60e6f93..76a57f04 100644 --- a/tests/wg-user-confidance.ts +++ b/tests/wg-user-confidance.ts @@ -476,10 +476,10 @@ function testTiltZ() { } function startIOMonitor() { - input.onButtonEvent(Button.A, ButtonEvent.Click, () => { + input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => { AWasPressed = true }) - input.onButtonEvent(Button.B, ButtonEvent.Click, () => { + input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => { BWasPressed = true }) input.onShake(() => { diff --git a/theme/style.less b/theme/style.less index 80ac291e..9d76b953 100644 --- a/theme/style.less +++ b/theme/style.less @@ -82,6 +82,12 @@ } } } +// Safari Only for iPad and iPhone second rule +@supports (-webkit-touch-callout: none) { + #mainmenu .right.menu { + margin-right: 4rem; + } +} /* Mobile */ @media only screen and (max-width: @largestMobileScreen) {