bring back deprecated blocks, but hide them
This commit is contained in:
		@@ -12,7 +12,7 @@ Tell everyone who you are. Show you name on the LEDs.
 | 
			
		||||
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.onPinEvent(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
input.onPinTouched(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -21,7 +21,7 @@ input.onPinEvent(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from `0` to `100` when pin **0** is pressed.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onPinEvent(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
input.onPinTouched(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
    basic.showNumber(Math.randomRange(0, 100));
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
@@ -35,7 +35,7 @@ Show ``"LOVE METER"`` on the screen when the @boardname@ starts.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
basic.showString("LOVE METER");
 | 
			
		||||
input.onPinEvent(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
input.onPinTouched(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
    basic.showNumber(Math.randomRange(0, 100));
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
 | 
			
		||||
input.onGesture(Gesture.Shake, () => {
 | 
			
		||||
    
 | 
			
		||||
});
 | 
			
		||||
input.onPinEvent(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
input.onPinTouched(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
    
 | 
			
		||||
});
 | 
			
		||||
input.buttonIsPressed(Button.A);
 | 
			
		||||
 
 | 
			
		||||
@@ -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.onPinEvent(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
input.onPinTouched(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.onPinEvent(TouchPin.P0, Button.Click, () => {
 | 
			
		||||
input.onPinTouched(TouchPin.P0, Button.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.onPinEvent(TouchPin.P0, ButtonEvent.Click, () => {
 | 
			
		||||
input.onPinTouched(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.onPinEvent(TouchPin.P0, ButtonEvent.Click, () => {
 | 
			
		||||
input.onPinTouched(TouchPin.P0, ButtonEvent.Click, () => {
 | 
			
		||||
    count = count + 1
 | 
			
		||||
    basic.showNumber(count, 100)
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -380,6 +380,9 @@
 | 
			
		||||
  "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",
 | 
			
		||||
@@ -387,9 +390,15 @@
 | 
			
		||||
  "input.onLogoDown|param|body": "TODO",
 | 
			
		||||
  "input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
 | 
			
		||||
  "input.onLogoUp|param|body": "TODO",
 | 
			
		||||
  "input.onPinEvent": "Do something when a pin is touched and released again (while also touching the GND pin).",
 | 
			
		||||
  "input.onPinEvent|param|body": "the code to run when event is fired on pin",
 | 
			
		||||
  "input.onPinEvent|param|name": "the pin, eg: TouchPin.P0",
 | 
			
		||||
  "input.onPinTouched": "Do something when a pin is touched and released again (while also touching the GND pin).",
 | 
			
		||||
  "input.onPinTouched|param|body": "the code to run when event is fired on pin",
 | 
			
		||||
  "input.onPinTouched|param|name": "the pin, eg: TouchPin.P0",
 | 
			
		||||
  "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.onScreenDown": "Attaches code to run when the screen is facing down.",
 | 
			
		||||
  "input.onScreenDown|param|body": "TODO",
 | 
			
		||||
  "input.onScreenUp": "Attaches code to run when the screen is facing up.",
 | 
			
		||||
 
 | 
			
		||||
@@ -311,8 +311,11 @@
 | 
			
		||||
  "input.lightLevel|block": "light level",
 | 
			
		||||
  "input.magneticForce|block": "magnetic force (µT)|%NAME",
 | 
			
		||||
  "input.onButtonEvent|block": "on button %NAME| is %eventType=control_button_event_value_id",
 | 
			
		||||
  "input.onButtonPressed|block": "on button|%NAME|pressed",
 | 
			
		||||
  "input.onGesture|block": "on |%NAME",
 | 
			
		||||
  "input.onPinEvent|block": "on pin %name|is %eventType=control_button_event_value_id",
 | 
			
		||||
  "input.onPinTouched|block": "on pin %name|is %eventType=control_button_event_value_id",
 | 
			
		||||
  "input.onPinPressed|block": "on pin %name|pressed",
 | 
			
		||||
  "input.onPinReleased|block": "on pin %NAME|released",
 | 
			
		||||
  "input.pinIsPressed|block": "pin %NAME|is pressed",
 | 
			
		||||
  "input.rotation|block": "rotation (°)|%NAME",
 | 
			
		||||
  "input.runningTimeMicros|block": "running time (micros)",
 | 
			
		||||
 
 | 
			
		||||
@@ -123,7 +123,7 @@
 | 
			
		||||
  <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">
 | 
			
		||||
  <block type="device_pin_touch" x="555" y="96">
 | 
			
		||||
    <field name="name">TouchPin.P2</field>
 | 
			
		||||
  </block>
 | 
			
		||||
</xml>
 | 
			
		||||
@@ -117,7 +117,7 @@
 | 
			
		||||
      </block>
 | 
			
		||||
    </statement>
 | 
			
		||||
  </block>
 | 
			
		||||
  <block type="device_pin_event" x="2407" y="0">
 | 
			
		||||
  <block type="device_pin_touch" x="2407" y="0">
 | 
			
		||||
    <field name="name">TouchPin.P2</field>
 | 
			
		||||
    <statement name="HANDLER">
 | 
			
		||||
      <block type="device_led_toggle">
 | 
			
		||||
 
 | 
			
		||||
@@ -190,8 +190,17 @@ namespace input {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Deprecated
 | 
			
		||||
    void onButtonPressed(Button button, int eventType, Action body) {
 | 
			
		||||
        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_pressed block="on button|%NAME|pressed"
 | 
			
		||||
    //% parts="buttonpair"
 | 
			
		||||
    //% blockHidden=true
 | 
			
		||||
    void onButtonPressed(Button button, Action body) {
 | 
			
		||||
        registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -232,9 +241,9 @@ namespace input {
 | 
			
		||||
     * @param name the pin, eg: TouchPin.P0
 | 
			
		||||
     * @param body the code to run when event is fired on pin
 | 
			
		||||
     */
 | 
			
		||||
    //% help=input/on-pin-event weight=83 blockGap=32
 | 
			
		||||
    //% blockId=device_pin_event block="on pin %name|is %eventType=control_button_event_value_id"
 | 
			
		||||
    void onPinEvent(TouchPin name, int eventType, Action body) {
 | 
			
		||||
    //% help=input/on-pin-touch weight=83 blockGap=32
 | 
			
		||||
    //% blockId=device_pin_touch block="on pin %name|is %eventType=control_button_event_value_id"
 | 
			
		||||
    void onPinTouched(TouchPin name, int eventType, Action body) {
 | 
			
		||||
        auto pin = getPin((int)name);
 | 
			
		||||
        if (!pin) return;
 | 
			
		||||
 | 
			
		||||
@@ -244,6 +253,14 @@ namespace input {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Deprecated
 | 
			
		||||
    /**
 | 
			
		||||
     * 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=32
 | 
			
		||||
    //% blockId=device_pin_input block="on pin %name|pressed"
 | 
			
		||||
    //% blockHidden=true
 | 
			
		||||
    void onPinPressed(TouchPin name, Action body) {
 | 
			
		||||
        auto pin = getPin((int)name);
 | 
			
		||||
        if (!pin) return;
 | 
			
		||||
@@ -254,6 +271,14 @@ namespace input {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Deprecated
 | 
			
		||||
    /**
 | 
			
		||||
     * 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"
 | 
			
		||||
    //% blockHidden=true
 | 
			
		||||
    void onPinReleased(TouchPin name, Action body) {
 | 
			
		||||
        auto pin = getPin((int)name);
 | 
			
		||||
        if (!pin) return;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										37
									
								
								libs/core/shims.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										37
									
								
								libs/core/shims.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -233,6 +233,17 @@ declare namespace input {
 | 
			
		||||
    //% parts="buttonpair" 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_pressed block="on button|%NAME|pressed"
 | 
			
		||||
    //% parts="buttonpair"
 | 
			
		||||
    //% blockHidden=true 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
 | 
			
		||||
@@ -259,9 +270,29 @@ declare namespace input {
 | 
			
		||||
     * @param name the pin, eg: TouchPin.P0
 | 
			
		||||
     * @param body the code to run when event is fired on pin
 | 
			
		||||
     */
 | 
			
		||||
    //% help=input/on-pin-event weight=83 blockGap=32
 | 
			
		||||
    //% blockId=device_pin_event block="on pin %name|is %eventType=control_button_event_value_id" shim=input::onPinEvent
 | 
			
		||||
    function onPinEvent(name: TouchPin, eventType: int32, body: () => void): void;
 | 
			
		||||
    //% help=input/on-pin-input weight=83 blockGap=32
 | 
			
		||||
    //% blockId=device_pin_touch block="on pin %name|is %eventType=control_button_event_value_id" shim=input::onPinTouched
 | 
			
		||||
    function onPinTouched(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=32
 | 
			
		||||
    //% blockId=device_pin_input block="on pin %name|pressed"
 | 
			
		||||
    //% blockHidden=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"
 | 
			
		||||
    //% blockHidden=true shim=input::onPinReleased
 | 
			
		||||
    function onPinReleased(name: TouchPin, body: () => void): void;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the button state (pressed or not) for ``A`` and ``B``.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
namespace pxsim.input {
 | 
			
		||||
    export function onPinEvent(pinId: number, pinEvent: number, handler: RefAction) {
 | 
			
		||||
    export function onPinTouched(pinId: number, pinEvent: number, handler: RefAction) {
 | 
			
		||||
        let pin = getPin(pinId);
 | 
			
		||||
        if (!pin) return;
 | 
			
		||||
        pin.isTouched();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user