Map and clean deprecated functions (#175)
* add image and deprecated arrow functions * update locales * map basic.showArrow * map arrow blocks * map & remove arrow images * remove arrow blocks * update locales * remove & patch: rgbw -> rgb button/pin pressed -> button/pin event loudness -> soundLevel * update ts mappings for arrows * add wip ts patch rules * update .blocks files * use Click instead of Down as default in Documentation and tests * patch test.blocks * fix lowercase name tag * update test.blocks * update blocks test files * update blocks test files * format block files * pass blocks file tests * fix ts mapping * fix color.defl value closes https://github.com/microsoft/pxt-calliope/issues/136 * fix ts mappings - add optional spacing at the end of rgbw() - map up to v4.0.19 * add suggested changes * replace innerText by textContent Co-authored-by: JW <gitkraken@juriwolf.de> Co-authored-by: Juri <info@juriwolf.de>
This commit is contained in:
parent
3b9d90e551
commit
a93febb5b7
@ -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(`
|
||||
. # . # .
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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))
|
||||
})
|
||||
```
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
})
|
||||
```
|
||||
|
@ -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")
|
||||
})
|
||||
```
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
})
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
});
|
||||
```
|
||||
|
@ -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) {
|
||||
|
@ -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")
|
||||
})
|
||||
```
|
||||
|
@ -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(`
|
||||
# . . . #
|
||||
|
@ -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
|
||||
})
|
||||
|
@ -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(`
|
||||
. . . . .
|
||||
# . # . .
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
})
|
||||
```
|
||||
|
@ -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)
|
@ -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();
|
||||
})
|
||||
```
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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++;
|
||||
})
|
||||
```
|
||||
|
@ -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();
|
||||
});
|
||||
```
|
||||
|
@ -9,7 +9,7 @@ An event handler is code that is associated with a particular event, such as "bu
|
||||
Functions named "on <event>" create an association between an event and the event handler code. For example, the following code registers the event handler (the code between the `do` and `end` keywords) with the event of a press of button A:
|
||||
|
||||
```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)
|
||||
})
|
||||
|
@ -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)
|
||||
})
|
||||
```
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
})
|
||||
|
@ -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();
|
||||
});
|
||||
```
|
||||
|
@ -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));
|
||||
});
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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)
|
||||
})
|
||||
```
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
@ -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)
|
@ -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);
|
||||
});
|
||||
```
|
||||
|
@ -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(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
|
@ -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);
|
||||
});
|
||||
```
|
||||
|
@ -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);
|
||||
});
|
||||
```
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
})
|
||||
```
|
||||
|
@ -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();
|
||||
})
|
||||
```
|
||||
|
@ -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)
|
||||
})
|
||||
|
@ -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)
|
||||
})
|
||||
|
@ -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)
|
||||
})
|
||||
|
@ -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)
|
||||
})
|
||||
|
@ -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)
|
||||
})
|
||||
|
@ -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)
|
||||
});
|
||||
```
|
||||
|
@ -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?");
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
})
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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(() => {
|
||||
|
@ -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))
|
||||
})
|
||||
```
|
||||
|
@ -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");
|
||||
})
|
||||
|
@ -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))
|
||||
})
|
||||
```
|
||||
|
@ -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")
|
||||
|
@ -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(() => {
|
||||
|
@ -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);
|
||||
});
|
||||
```
|
||||
|
@ -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")
|
||||
|
@ -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(`
|
||||
# # . # #
|
||||
# # . # #
|
||||
|
@ -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(`
|
||||
|
@ -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)
|
||||
|
165
editor/patch.ts
165
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
|
||||
/*
|
||||
<block type="device_button_event" x="354" y="30">
|
||||
<field name="NAME">Button.A</field>
|
||||
</block>
|
||||
<block type="device_pin_event" x="610" y="33">
|
||||
<field name="name">TouchPin.P0</field>
|
||||
</block>
|
||||
<block type="device_pin_released" x="361" y="158">
|
||||
<field name="NAME">TouchPin.P1</field>
|
||||
</block>
|
||||
|
||||
converts to
|
||||
|
||||
<block type="device_button_selected_event" x="35" y="429">
|
||||
<field name="NAME">Button.B</field>
|
||||
<value name="eventType">
|
||||
<shadow type="control_button_event_value_id">
|
||||
<field name="id">ButtonEvent.Click</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
<block type="device_pin_custom_event" x="368" y="428">
|
||||
<field name="NAME">TouchPin.P2</field>
|
||||
<value name="eventType">
|
||||
<shadow type="control_button_event_value_id">
|
||||
<field name="id">ButtonEvent.Up</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
*/
|
||||
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
|
||||
/*
|
||||
<block type="loudness" />
|
||||
|
||||
converts to
|
||||
|
||||
<block type="soundLevel" />
|
||||
*/
|
||||
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
|
||||
/*
|
||||
<block type="basic_show_arrow">
|
||||
<value name="i">
|
||||
<shadow type="device_arrow">
|
||||
<field name="arrow">ArrowNames.North</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
|
||||
converts to
|
||||
|
||||
<block type="basic_show_icon">
|
||||
<mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="false"></mutation>
|
||||
<field name="i">IconNames.ArrowNorth</field>
|
||||
</block>
|
||||
*/
|
||||
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
|
||||
/*
|
||||
<block type="builtin_arrow_image">
|
||||
<field name="i">ArrowNames.East</field>
|
||||
</block>
|
||||
|
||||
converts to
|
||||
|
||||
<block type="builtin_image">
|
||||
<field name="i">IconNames.ArrowEast</field>
|
||||
</block>
|
||||
*/
|
||||
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
|
||||
/**
|
||||
* <block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
@ -40,11 +194,6 @@
|
||||
</block>
|
||||
*/
|
||||
|
||||
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
|
||||
/*
|
||||
<block type="radio_on_packet" x="174" y="120">
|
||||
@ -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");
|
||||
|
@ -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"
|
||||
}
|
@ -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",
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,53 +1,125 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<variables>
|
||||
<variable type="" id="PGGhch1kuMF##st8~wFr">receivedNumber</variable>
|
||||
</variables>
|
||||
<block type="pxt-on-start" x="77" y="38">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_show_number">
|
||||
<value name="number">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">12</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="basic_show_icon">
|
||||
<field name="i">IconNames.Umbrella</field>
|
||||
<next>
|
||||
<block type="device_print_message">
|
||||
<value name="text">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">hi!</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_pause">
|
||||
<value name="pause">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">100</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_clear_display">
|
||||
<next>
|
||||
<block type="device_pause">
|
||||
<value name="pause">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">100</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="device_forever" x="418" y="25"></block>
|
||||
<xml xmlns="https://developers.google.com/blockly/xml">
|
||||
<variables>
|
||||
<variable id="PGGhch1kuMF##st8~wFr">receivedNumber</variable>
|
||||
</variables>
|
||||
<block type="pxt-on-start" x="-307" y="-128">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_show_number">
|
||||
<value name="number">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">12</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_show_number">
|
||||
<value name="number">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="basic_show_icon">
|
||||
<field name="i">IconNames.Umbrella</field>
|
||||
<next>
|
||||
<block type="basic_show_icon">
|
||||
<field name="i">IconNames.Heart</field>
|
||||
<next>
|
||||
<block type="device_print_message">
|
||||
<value name="text">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">hi!</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_print_message">
|
||||
<value name="text">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">hi!</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_pause">
|
||||
<value name="pause">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">100</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_clear_display">
|
||||
<next>
|
||||
<block type="device_show_leds">
|
||||
<field name="LEDS">`
|
||||
. . . . #
|
||||
. . . # .
|
||||
. . # . .
|
||||
. # . . .
|
||||
# . . . .
|
||||
`</field>
|
||||
<next>
|
||||
<block type="device_set_led_color">
|
||||
<value name="color">
|
||||
<shadow type="colorNumberPicker">
|
||||
<field name="value">0xff0000</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_show_number">
|
||||
<value name="number">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="core_rgb">
|
||||
<value name="red">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">255</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<value name="green">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">255</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<value name="blue">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">255</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="basic_show_compass">
|
||||
<value name="interval">
|
||||
<shadow type="timePicker">
|
||||
<field name="ms">600</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_turn_rgb_led_off" />
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="device_forever" x="412" y="-30" />
|
||||
</xml>
|
@ -1,38 +1,53 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<variables>
|
||||
<variable type="" id="tgDN]qF_Ah1Z*?=|+?^Y">item</variable>
|
||||
</variables>
|
||||
<block type="pxt-on-start" x="-29" y="116">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_show_image_offset">
|
||||
<value name="sprite">
|
||||
<block type="builtin_image">
|
||||
<field name="i">IconNames.Heart</field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="offset">
|
||||
<shadow type="math_number" id="KX(1%=^vQUd=Q`UHhD*n">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_scroll_image">
|
||||
<value name="frameoffset">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">1</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<value name="delay">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">200</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="variables_get" disabled="true" x="145" y="168">
|
||||
<field name="VAR" id="tgDN]qF_Ah1Z*?=|+?^Y" variabletype="">item</field>
|
||||
</block>
|
||||
<xml xmlns="https://developers.google.com/blockly/xml">
|
||||
<variables>
|
||||
<variable id="tgDN]qF_Ah1Z*?=|+?^Y">item</variable>
|
||||
</variables>
|
||||
<block type="pxt-on-start" x="48" y="151">
|
||||
<statement name="HANDLER">
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="tgDN]qF_Ah1Z*?=|+?^Y">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="builtin_image">
|
||||
<field name="i">IconNames.Yes</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_show_image_offset">
|
||||
<value name="sprite">
|
||||
<block type="builtin_image">
|
||||
<field name="i">IconNames.Heart</field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="offset">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_scroll_image">
|
||||
<value name="sprite">
|
||||
<block type="variables_get">
|
||||
<field name="VAR" id="tgDN]qF_Ah1Z*?=|+?^Y">item</field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="frameoffset">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">1</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<value name="delay">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">200</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
</xml>
|
@ -1,132 +1,141 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<variables>
|
||||
<variable type="" id="wUkGVHoc@p^mter~Rc7h">item</variable>
|
||||
<variable type="" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</variable>
|
||||
</variables>
|
||||
<block type="device_button_event" x="-6" y="17">
|
||||
<field name="NAME">Button.AB</field>
|
||||
<statement name="HANDLER">
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h" variabletype="">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="*jGI?[NsA.f}=qk0RHHf">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_button2">
|
||||
<field name="NAME">Button.B</field>
|
||||
</block>
|
||||
<xml xmlns="https://developers.google.com/blockly/xml">
|
||||
<variables>
|
||||
<variable id="wUkGVHoc@p^mter~Rc7h">item</variable>
|
||||
<variable id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</variable>
|
||||
</variables>
|
||||
<block type="device_button_selected_event" x="0" y="0">
|
||||
<field name="NAME">Button.AB</field>
|
||||
<value name="eventType">
|
||||
<shadow type="control_button_event_value_id"></shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h" variabletype="">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="*jGI?[NsA.f}=qk0RHHf">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_pin_is_pressed">
|
||||
<field name="NAME">TouchPin.P1</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
|
||||
<statement name="HANDLER">
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_acceleration">
|
||||
<field name="NAME">Dimension.Y</field>
|
||||
</block>
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_button2">
|
||||
<field name="NAME">Button.B</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_light_level"></block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="wUkGVHoc@p^mter~Rc7h">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_heading"></block>
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_pin_is_pressed">
|
||||
<field name="NAME">TouchPin.P1</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="bZBPUCLiZ6#D@e_[Y`:0">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_temperature"></block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="o~k},FK*r@[O2)Cy!lM}">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_rotation">
|
||||
<field name="NAME">Rotation.Roll</field>
|
||||
</block>
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_acceleration">
|
||||
<field name="NAME">Dimension.Y</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="Uu,ZpYs7!BzIpX`%V_^!">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_magnetic_force">
|
||||
<field name="NAME">Dimension.Z</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;" variabletype="">sdfsadf</field>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="s{USu#UBc84Ao*jy(EQC">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_running_time"></block>
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_light_level" />
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_set_accelerometer_range">
|
||||
<field name="range">AcceleratorRange.TwoG</field>
|
||||
</block>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_heading" />
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_temperature" />
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_rotation">
|
||||
<field name="NAME">Rotation.Roll</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_magnetic_force">
|
||||
<field name="NAME">Dimension.Z</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id=")f$ml.CVl6|1^?sPWl:;">sdfsadf</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_get_running_time" />
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_set_accelerometer_range">
|
||||
<field name="range">AcceleratorRange.TwoG</field>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="device_gesture_event" x="472" y="-8">
|
||||
<field name="NAME">Gesture.SixG</field>
|
||||
</block>
|
||||
<block type="device_pin_event" x="555" y="96">
|
||||
<field name="name">TouchPin.P2</field>
|
||||
</block>
|
||||
<block type="device_pin_released" x="188" y="435">
|
||||
<field name="NAME">TouchPin.P2</field>
|
||||
</block>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="device_gesture_event" x="555" y="30">
|
||||
<field name="NAME">Gesture.SixG</field>
|
||||
</block>
|
||||
<block type="device_pin_custom_event" x="556" y="156">
|
||||
<field name="name">TouchPin.P0</field>
|
||||
<value name="eventType">
|
||||
<shadow type="control_button_event_value_id"></shadow>
|
||||
</value>
|
||||
</block>
|
||||
<block type="device_pin_custom_event" x="560" y="274">
|
||||
<field name="name">TouchPin.P0</field>
|
||||
<value name="eventType">
|
||||
<shadow type="control_button_event_value_id"></shadow>
|
||||
</value>
|
||||
</block>
|
||||
</xml>
|
29
libs/core/blocks-test/motors.blocks
Normal file
29
libs/core/blocks-test/motors.blocks
Normal file
@ -0,0 +1,29 @@
|
||||
<xml xmlns="https://developers.google.com/blockly/xml">
|
||||
<block type="pxt-on-start" x="20" y="20">
|
||||
<statement name="HANDLER">
|
||||
<block type="motor_on">
|
||||
<value name="percent">
|
||||
<shadow type="speedPicker">
|
||||
<field name="speed">100</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="motor_command">
|
||||
<field name="command">MotorCommand.Break</field>
|
||||
<next>
|
||||
<block type="block_dual_motor">
|
||||
<field name="motor">Motor.A</field>
|
||||
<value name="percent">
|
||||
<shadow type="speedPicker">
|
||||
<field name="speed">100</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="device_forever" x="294" y="22" />
|
||||
</xml>
|
@ -1,95 +1,94 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<variables>
|
||||
<variable type="" id="I3xB5Q]ehg#-~(sq{[|E">item</variable>
|
||||
</variables>
|
||||
<block type="melody_on_event" x="-27" y="128">
|
||||
<field name="value">MusicEvent.BackgroundMelodyStarted</field>
|
||||
<statement name="HANDLER">
|
||||
<block type="device_play_note">
|
||||
<value name="note">
|
||||
<shadow type="device_note">
|
||||
<field name="name">175</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<value name="duration">
|
||||
<shadow type="device_beat">
|
||||
<field name="fraction">BeatFraction.Sixteenth</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_ring">
|
||||
<value name="note">
|
||||
<shadow type="device_note">
|
||||
<field name="name">147</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_rest">
|
||||
<xml xmlns="https://developers.google.com/blockly/xml">
|
||||
<variables>
|
||||
<variable id="I3xB5Q]ehg#-~(sq{[|E">item</variable>
|
||||
</variables>
|
||||
<block type="device_forever" x="21" y="128">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_play_note">
|
||||
<value name="note">
|
||||
<shadow type="device_note">
|
||||
<field name="name">175</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<value name="duration">
|
||||
<shadow type="device_beat">
|
||||
<field name="fraction">BeatFraction.Sixteenth</field>
|
||||
</shadow>
|
||||
<shadow type="device_beat">
|
||||
<field name="fraction">BeatFraction.Sixteenth</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E" variabletype="">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="8/Ht9pG0DuL-0~sPe},^">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_note">
|
||||
<field name="name">466</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E" variabletype="">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="8/Ht9pG0DuL-0~sPe},^">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_beat">
|
||||
<field name="fraction">BeatFraction.Sixteenth</field>
|
||||
</block>
|
||||
<block type="device_ring">
|
||||
<value name="note">
|
||||
<shadow type="device_note">
|
||||
<field name="name">147</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E" variabletype="">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number" id="8/Ht9pG0DuL-0~sPe},^">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_tempo"></block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_change_tempo">
|
||||
<value name="value">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">1242</field>
|
||||
</shadow>
|
||||
<block type="device_rest">
|
||||
<value name="duration">
|
||||
<shadow type="device_beat">
|
||||
<field name="fraction">BeatFraction.Sixteenth</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_set_tempo">
|
||||
<value name="value">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">5</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_note">
|
||||
<field name="name">466</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_beat">
|
||||
<field name="fraction">BeatFraction.Sixteenth</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="variables_set">
|
||||
<field name="VAR" id="I3xB5Q]ehg#-~(sq{[|E">item</field>
|
||||
<value name="VALUE">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
<block type="device_tempo" />
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_change_tempo">
|
||||
<value name="value">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">1242</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="device_set_tempo">
|
||||
<value name="value">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">5</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
</xml>
|
@ -59,8 +59,8 @@
|
||||
</value>
|
||||
<next>
|
||||
<block type="serial_redirect">
|
||||
<field name="tx">SerialPin.P12</field>
|
||||
<field name="rx">SerialPin.P13</field>
|
||||
<field name="tx">SerialPin.C16</field>
|
||||
<field name="rx">SerialPin.C17</field>
|
||||
<field name="rate">BaudRate.BaudRate28800</field>
|
||||
<next>
|
||||
<block type="serial_writebuffer">
|
||||
|
File diff suppressed because one or more lines are too long
@ -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();
|
||||
});
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
// }
|
||||
// }
|
||||
|
40
libs/core/shims.d.ts
vendored
40
libs/core/shims.d.ts
vendored
@ -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
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
|
@ -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 () {
|
||||
|
@ -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 () {
|
||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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(() => {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user