more images

This commit is contained in:
Peli de Halleux
2017-11-16 12:58:37 -08:00
parent dab281a9cb
commit 9437873427
10 changed files with 114 additions and 108 deletions

View File

@@ -35,12 +35,28 @@ namespace sensors {
return DAL.DEVICE_TYPE_TOUCH
}
/**
* Do something when a 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
* @param body code to run when the event is raised
*/
//% help=input/touch/on-event
//% blockId=touchEvent block="on `icons.touchSensor` %sensor|%event"
//% parts="touch"
//% blockNamespace=sensors
//% weight=99 blockGap=8
//% group="Touch Sensor"
onEvent(ev: TouchSensorEvent, body: () => void) {
this.button.onEvent(<ButtonEvent><number>ev, body)
}
/**
* Check if touch sensor is touched.
* @param sensor the port to query the request
*/
//% help=input/touch/is-touched
//% block="%sensor|is touched"
//% block="`icons.touchSensor` %sensor|is touched"
//% blockId=touchIsTouched
//% parts="touch"
//% blockNamespace=sensors
@@ -49,30 +65,14 @@ namespace sensors {
isTouched() {
return this.button.isPressed();
}
/**
* Do something when a 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
* @param body code to run when the event is raised
*/
//% help=input/touch/on-event
//% blockId=touchEvent block="on %sensor|%event"
//% parts="touch"
//% blockNamespace=sensors
//% weight=99 blockGap=8
//% group="Touch Sensor"
onEvent(ev: TouchSensorEvent, body: () => void) {
this.button.onEvent(<ButtonEvent><number>ev, body)
}
}
//% whenUsed block="`icons.touchSensor` 1" weight=95 fixedInstance
//% whenUsed block="1" weight=95 fixedInstance
export const touchSensor1: TouchSensor = new TouchSensor(1)
//% whenUsed block="`icons.touchSensor` 2" weight=95 fixedInstance
//% whenUsed block="2" weight=95 fixedInstance
export const touchSensor2: TouchSensor = new TouchSensor(2)
//% whenUsed block="`icons.touchSensor` 3" weight=95 fixedInstance
//% whenUsed block="3" weight=95 fixedInstance
export const touchSensor3: TouchSensor = new TouchSensor(3)
//% whenUsed block="`icons.touchSensor` 4" weight=95 fixedInstance
//% whenUsed block="4" weight=95 fixedInstance
export const touchSensor4: TouchSensor = new TouchSensor(4)
}