adding "pin is pressed" block

This commit is contained in:
Peli de Halleux 2016-07-26 13:51:41 -07:00
parent aff9d1ee60
commit 8440f7c763
2 changed files with 11 additions and 17 deletions

View File

@ -167,6 +167,17 @@ namespace input {
return false; 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. * Get the current compass compass heading in degrees.
@ -270,16 +281,6 @@ namespace input {
//% help=input/calibrate weight=0 //% help=input/calibrate weight=0
void calibrate() { } 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. * Sets the accelerometer sample range in gravities.
* @param range a value describe the maximum strengh of acceleration measured * @param range a value describe the maximum strengh of acceleration measured

View File

@ -290,13 +290,6 @@ declare namespace input {
//% help=input/calibrate weight=0 shim=input::calibrate //% help=input/calibrate weight=0 shim=input::calibrate
function calibrate(): void; 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. * Sets the accelerometer sample range in gravities.
* @param range a value describe the maximum strengh of acceleration measured * @param range a value describe the maximum strengh of acceleration measured