V4updates (#185)
* update 32KB * reorder buttonEvents to have clicked as default * update event block documentation file path * remove on pin released documentation * update shims, enums and package-lock
This commit is contained in:
parent
75d7bfb7c2
commit
2457725e0c
@ -1,4 +1,4 @@
|
|||||||
# On Button Pressed
|
# On Button Event
|
||||||
|
|
||||||
Start an [event handler](/reference/event-handler) (part of the program that will run when something happens, like when a button is pressed).
|
Start an [event handler](/reference/event-handler) (part of the program that will run when something happens, like when a button is pressed).
|
||||||
This handler works when button `A` or `B` is pressed, or `A` and `B` together.
|
This handler works when button `A` or `B` is pressed, or `A` and `B` together.
|
@ -1,4 +1,4 @@
|
|||||||
# On Pin Pressed
|
# On Pin Event
|
||||||
|
|
||||||
Start an [event handler](/reference/event-handler) (part of the
|
Start an [event handler](/reference/event-handler) (part of the
|
||||||
program that will run when something happens, like when a button is
|
program that will run when something happens, like when a button is
|
@ -1,48 +0,0 @@
|
|||||||
# On Pin Released
|
|
||||||
|
|
||||||
Start an [event handler](/reference/event-handler) (part of the
|
|
||||||
program that will run when something happens, like when a button is
|
|
||||||
pressed). This handler works when you release pin `0`, `1`, or `2`
|
|
||||||
together with `GND`. When you are using this function in a web
|
|
||||||
browser, click and release the pins on the screen instead of the ones on the
|
|
||||||
@boardname@.
|
|
||||||
|
|
||||||
If you hold the `GND` pin with one hand and touch pin `0`, `1`, or `2`
|
|
||||||
with the other, a very small (safe) amount of electricity will flow
|
|
||||||
through your body and back into the @boardname@. This is called
|
|
||||||
**completing a circuit**. It's like you're a big wire!
|
|
||||||
|
|
||||||
```sig
|
|
||||||
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => {
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## ~hint
|
|
||||||
|
|
||||||
This function works best when the @boardname@ is using batteries for power,
|
|
||||||
instead of the USB cable.
|
|
||||||
|
|
||||||
## ~
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
* ``name`` means the pin that is being released, either `P0`, `P1`, or `P2`
|
|
||||||
|
|
||||||
## Example: pin pressed counter
|
|
||||||
|
|
||||||
This program counts how many times you release the `P0` pin.
|
|
||||||
Every time you release the pin, the program shows the number of times on the screen.
|
|
||||||
|
|
||||||
```blocks
|
|
||||||
let count = 0
|
|
||||||
basic.showNumber(count, 100)
|
|
||||||
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => {
|
|
||||||
count = count + 1
|
|
||||||
basic.showNumber(count, 100)
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## See also
|
|
||||||
|
|
||||||
[@boardname@ pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
|
|
||||||
|
|
12
libs/core/enums.d.ts
vendored
12
libs/core/enums.d.ts
vendored
@ -41,17 +41,17 @@ declare namespace basic {
|
|||||||
|
|
||||||
declare const enum ButtonEvent {
|
declare const enum ButtonEvent {
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
//% block="pressed down"
|
|
||||||
Down = 1, // MICROBIT_BUTTON_EVT_DOWN
|
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
|
||||||
//% block="released up"
|
|
||||||
Up = 2, // MICROBIT_BUTTON_EVT_UP
|
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
|
||||||
//% block="clicked"
|
//% block="clicked"
|
||||||
Click = 3, // MICROBIT_BUTTON_EVT_CLICK
|
Click = 3, // MICROBIT_BUTTON_EVT_CLICK
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
//% block="long clicked"
|
//% block="long clicked"
|
||||||
LongClick = 4, // MICROBIT_BUTTON_EVT_LONG_CLICK
|
LongClick = 4, // MICROBIT_BUTTON_EVT_LONG_CLICK
|
||||||
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
|
//% block="pressed down"
|
||||||
|
Down = 1, // MICROBIT_BUTTON_EVT_DOWN
|
||||||
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
|
//% block="released up"
|
||||||
|
Up = 2, // MICROBIT_BUTTON_EVT_UP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,18 +8,18 @@ enum class Button {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class ButtonEvent {
|
enum class ButtonEvent {
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
|
||||||
//% block="pressed down"
|
|
||||||
Down = MICROBIT_BUTTON_EVT_DOWN,
|
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
|
||||||
//% block="released up"
|
|
||||||
Up = MICROBIT_BUTTON_EVT_UP,
|
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
//% block="clicked"
|
//% block="clicked"
|
||||||
Click = MICROBIT_BUTTON_EVT_CLICK,
|
Click = MICROBIT_BUTTON_EVT_CLICK,
|
||||||
//% blockIdentity="input.buttonEventValueId"
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
//% block="long clicked"
|
//% block="long clicked"
|
||||||
LongClick = MICROBIT_BUTTON_EVT_LONG_CLICK,
|
LongClick = MICROBIT_BUTTON_EVT_LONG_CLICK,
|
||||||
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
|
//% block="pressed down"
|
||||||
|
Down = MICROBIT_BUTTON_EVT_DOWN,
|
||||||
|
//% blockIdentity="input.buttonEventValueId"
|
||||||
|
//% block="released up"
|
||||||
|
Up = MICROBIT_BUTTON_EVT_UP,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Dimension {
|
enum class Dimension {
|
||||||
@ -187,7 +187,7 @@ namespace input {
|
|||||||
//% parts="buttonpair"
|
//% parts="buttonpair"
|
||||||
//% group="Events"
|
//% group="Events"
|
||||||
void onButtonEvent(Button button, int eventType, Action body) {
|
void onButtonEvent(Button button, int eventType, Action body) {
|
||||||
registerWithDal((int)button, eventType, body);
|
registerWithDal((int)button, (int)eventType, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,7 +230,7 @@ namespace input {
|
|||||||
* @param name the pin, eg: TouchPin.P0
|
* @param name the pin, eg: TouchPin.P0
|
||||||
* @param body the code to run when event is fired on pin
|
* @param body the code to run when event is fired on pin
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-touch weight=99 blockGap=16
|
//% help=input/on-pin-event weight=99 blockGap=16
|
||||||
//% blockId=device_pin_custom_event block="on pin %name| %eventType=control_button_event_value_id"
|
//% blockId=device_pin_custom_event block="on pin %name| %eventType=control_button_event_value_id"
|
||||||
//% group="Events"
|
//% group="Events"
|
||||||
void onPinTouchEvent(TouchPin name, int eventType, Action body) {
|
void onPinTouchEvent(TouchPin name, int eventType, Action body) {
|
||||||
@ -239,7 +239,7 @@ namespace input {
|
|||||||
|
|
||||||
// Forces the PIN to switch to makey-makey style detection.
|
// Forces the PIN to switch to makey-makey style detection.
|
||||||
pin->isTouched();
|
pin->isTouched();
|
||||||
registerWithDal((int)name, eventType, body);
|
registerWithDal((int)name, (int)eventType, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +140,7 @@
|
|||||||
"microbit-dal": {
|
"microbit-dal": {
|
||||||
"stack_size": 2048,
|
"stack_size": 2048,
|
||||||
"sram_end": "0x20008000",
|
"sram_end": "0x20008000",
|
||||||
"RAM_SIZE": "\"16K\""
|
"RAM_SIZE": "\"32K\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
2
libs/core/shims.d.ts
vendored
2
libs/core/shims.d.ts
vendored
@ -277,7 +277,7 @@ declare namespace input {
|
|||||||
* @param name the pin, eg: TouchPin.P0
|
* @param name the pin, eg: TouchPin.P0
|
||||||
* @param body the code to run when event is fired on pin
|
* @param body the code to run when event is fired on pin
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-touch weight=99 blockGap=16
|
//% help=input/on-pin-event weight=99 blockGap=16
|
||||||
//% blockId=device_pin_custom_event block="on pin %name| %eventType=control_button_event_value_id"
|
//% blockId=device_pin_custom_event block="on pin %name| %eventType=control_button_event_value_id"
|
||||||
//% group="Events" shim=input::onPinTouchEvent
|
//% group="Events" shim=input::onPinTouchEvent
|
||||||
function onPinTouchEvent(name: TouchPin, eventType: int32, body: () => void): void;
|
function onPinTouchEvent(name: TouchPin, eventType: int32, body: () => void): void;
|
||||||
|
6801
package-lock.json
generated
6801
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user