adding waitUntil to buttons

This commit is contained in:
Peli de Halleux
2017-11-30 10:05:00 -08:00
parent 305a650125
commit a92edcffee
6 changed files with 34 additions and 0 deletions

View File

@ -3,5 +3,6 @@
"sensors.TouchSensor.isPressed": "Check if touch sensor is touched.",
"sensors.TouchSensor.onEvent": "Do something when a touch sensor is touched...",
"sensors.TouchSensor.onEvent|param|body": "code to run when the event is raised",
"sensors.TouchSensor.waitUntil": "Wait until the touch sensor is touched",
"sensors.TouchSensor.wasPressed": "Check if touch sensor is touched since it was last checked."
}

View File

@ -4,6 +4,7 @@
"TouchSensorEvent.Released|block": "released",
"sensors.TouchSensor.isPressed|block": "`icons.touchSensor` %sensor|is pressed",
"sensors.TouchSensor.onEvent|block": "on `icons.touchSensor` %sensor|%event",
"sensors.TouchSensor.waitUntil|block": "wait until `icons.touchSensor` %sensor|%event",
"sensors.TouchSensor.wasPressed|block": "`icons.touchSensor` %sensor|was pressed",
"sensors.touchSensor1|block": "1",
"sensors.touchSensor2|block": "2",

View File

@ -51,6 +51,21 @@ namespace sensors {
this.button.onEvent(<ButtonEvent><number>ev, body)
}
/**
* Wait until the touch sensor is touched
* @param sensor the touch sensor that needs to be clicked or used
* @param event the kind of button gesture that needs to be detected
*/
//% help=input/touch-sensor/wait-until
//% blockId=touchWaitUntil block="wait until `icons.touchSensor` %sensor|%event"
//% parts="touch"
//% blockNamespace=sensors
//% weight=98 blockGap=8
//% group="Touch Sensor"
waitUntil(ev: TouchSensorEvent) {
this.button.waitUntil(<ButtonEvent><number>ev);
}
/**
* Check if touch sensor is touched.
* @param sensor the port to query the request