From 8440f7c763c6b4b8f8b95a756d24af1607869ee1 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 26 Jul 2016 13:51:41 -0700 Subject: [PATCH] adding "pin is pressed" block --- libs/microbit/input.cpp | 21 +++++++++++---------- libs/microbit/shims.d.ts | 7 ------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/libs/microbit/input.cpp b/libs/microbit/input.cpp index c5f54569..efc4e2f4 100644 --- a/libs/microbit/input.cpp +++ b/libs/microbit/input.cpp @@ -167,6 +167,17 @@ namespace input { return false; } + /** + * Get the pin state (pressed or not). Requires to hold the ground to close the circuit. + * @param name pin used to detect the touch + */ + //% help=input/pin-is-pressed weight=56 + //% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094" + //% blockGap=8 + bool pinIsPressed(TouchPin name) { + auto pin = getPin((int)name); + return pin && pin->isTouched(); + } /** * Get the current compass compass heading in degrees. @@ -270,16 +281,6 @@ namespace input { //% help=input/calibrate weight=0 void calibrate() { } - /** - * Get the pin state (pressed or not). Requires to hold the ground to close the circuit. - * @param name pin used to detect the touch - */ - //% help=input/pin-is-pressed weight=58 block="pin|%NAME|is pressed" icon="\uf094" - bool pinIsPressed(TouchPin name) { - auto pin = getPin((int)name); - return pin && pin->isTouched(); - } - /** * Sets the accelerometer sample range in gravities. * @param range a value describe the maximum strengh of acceleration measured diff --git a/libs/microbit/shims.d.ts b/libs/microbit/shims.d.ts index c600e641..54910648 100644 --- a/libs/microbit/shims.d.ts +++ b/libs/microbit/shims.d.ts @@ -290,13 +290,6 @@ declare namespace input { //% help=input/calibrate weight=0 shim=input::calibrate function calibrate(): void; - /** - * Get the pin state (pressed or not). Requires to hold the ground to close the circuit. - * @param name pin used to detect the touch - */ - //% help=input/pin-is-pressed weight=58 block="pin|%NAME|is pressed" icon="\uf094" shim=input::pinIsPressed - function pinIsPressed(name: TouchPin): boolean; - /** * Sets the accelerometer sample range in gravities. * @param range a value describe the maximum strengh of acceleration measured