From 39071b56269232d0aaab69adc7c449360535a293 Mon Sep 17 00:00:00 2001 From: HelenFoster Date: Fri, 28 Jul 2017 18:05:53 +0100 Subject: [PATCH] Explain what pressed events do (#469) --- docs/reference/input/on-button-pressed.md | 3 +++ docs/reference/input/on-pin-pressed.md | 5 +++-- libs/core/_locales/core-jsdoc-strings.json | 4 ++-- libs/core/input.cpp | 4 ++-- libs/core/shims.d.ts | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/reference/input/on-button-pressed.md b/docs/reference/input/on-button-pressed.md index ede3f410..50e6884e 100644 --- a/docs/reference/input/on-button-pressed.md +++ b/docs/reference/input/on-button-pressed.md @@ -5,6 +5,9 @@ This handler works when button `A` or `B` is pressed, or `A` and `B` together. When you are using this function in a web browser, click the buttons on the screen instead of the ones on the @boardname@. +* For button `A` or `B`: This handler works when the button is pushed down and released within 1 second. +* 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, () => {}) ``` diff --git a/docs/reference/input/on-pin-pressed.md b/docs/reference/input/on-pin-pressed.md index b5ac4f98..084342fd 100644 --- a/docs/reference/input/on-pin-pressed.md +++ b/docs/reference/input/on-pin-pressed.md @@ -2,8 +2,9 @@ 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 press pin `0`, `1`, or `2` -together with `GND`. When you are using this function in a web +pressed). This handler works when you touch pin `0`, `1`, or `2` +together with `GND`, and release it within 1 second. +When you are using this function in a web browser, click the pins on the screen instead of the ones on the @boardname@. diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 3544b19c..99194fca 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -110,7 +110,7 @@ "input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.", "input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.", "input.magneticForce|param|dimension": "TODO", - "input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed", + "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).", @@ -120,7 +120,7 @@ "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.onPinPressed": "Do something when a pin is pressed.", + "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.", diff --git a/libs/core/input.cpp b/libs/core/input.cpp index 2711d2f2..d6932473 100644 --- a/libs/core/input.cpp +++ b/libs/core/input.cpp @@ -150,7 +150,7 @@ enum class MesDpadButtonInfo { //% color=#B4009E weight=99 icon="\uf192" namespace input { /** - * Do something when a button (``A``, ``B`` or both ``A+B``) is pressed + * 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 */ @@ -180,7 +180,7 @@ namespace input { } /** - * Do something when a pin is pressed. + * 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 */ diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 3ee9b121..2cec45fd 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -216,7 +216,7 @@ declare namespace basic { declare namespace input { /** - * Do something when a button (``A``, ``B`` or both ``A+B``) is pressed + * 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 */ @@ -237,7 +237,7 @@ declare namespace input { function onGesture(gesture: Gesture, body: () => void): void; /** - * Do something when a pin is pressed. + * 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 */