update input blocks in docs and tests

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

View File

@ -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.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.calibrateCompass();
})
```

View File

@ -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.input.onButtonEvent(Button.AB, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
input.calibrateCompass();
})
```

View File

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

View File

@ -9,7 +9,7 @@ on the @boardname@.
* For `A` and `B` together: This handler works when `A` and `B` are both pushed down, then one of them is released within 1.5 seconds of pushing down the second button.
```sig
input.onButtonPressed(Button.A, () => {})
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {})
```
Find out how buttons provide input to the @boardname@ in this video:
@ -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.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_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.input.onButtonEvent(Button.B, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
let dice = Math.randomRange(0, 5) + 1
basic.showNumber(dice)
})

View File

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

View File

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

View File

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