moving touch stuff into separate projects
This commit is contained in:
parent
580b40876c
commit
f22edac84d
@ -14,7 +14,6 @@
|
||||
"MMap.setNumber": "Write a number in specified format in the buffer.",
|
||||
"MMap.slice": "Read a range of bytes into a buffer.",
|
||||
"MMap.write": "Perform write(2) on the underlaying file",
|
||||
"TouchSensorEvent": "Touch sensor interactions",
|
||||
"brick.Button": "Generic button class, for device buttons and sensors.",
|
||||
"brick.Button.isPressed": "Check if button is currently pressed or not.",
|
||||
"brick.Button.onEvent": "Do something when a button or sensor is clicked, up or down.",
|
||||
@ -86,9 +85,6 @@
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent": "Do something when a button or sensor is clicked, up or down",
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent|param|body": "code to run when the event is raised",
|
||||
"sensors.RemoteInfraredBeaconButton.wasPressed": "See if the remote button was pressed again since the last time you checked.",
|
||||
"sensors.TouchSensor.isTouched": "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.UltraSonicSensor.distance": "Gets the distance from the sonar in millimeters",
|
||||
"sensors.UltraSonicSensor.on": "Registers code to run when the given color is close",
|
||||
"sensors.UltraSonicSensor.on|param|handler": "the code to run when detected",
|
||||
|
@ -27,9 +27,6 @@
|
||||
"Output.B|block": "B",
|
||||
"Output.C|block": "C",
|
||||
"Output.D|block": "D",
|
||||
"TouchSensorEvent.Bumped|block": "bumped",
|
||||
"TouchSensorEvent.Pressed|block": "pressed",
|
||||
"TouchSensorEvent.Released|block": "released",
|
||||
"UltrasonicSensorEvent.ObjectDetected|block": "object detected",
|
||||
"UltrasonicSensorEvent.ObjectNear|block": "object near",
|
||||
"brick.Button.isPressed|block": "`icons.brickButtons` %button|is pressed",
|
||||
@ -82,8 +79,6 @@
|
||||
"sensors.RemoteInfraredBeaconButton.isPressed|block": "`icons.infraredSensor` %button|is pressed",
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent|block": "on `icons.infraredSensor` %button|%event",
|
||||
"sensors.RemoteInfraredBeaconButton.wasPressed|block": "`icons.infraredSensor` %button|was pressed",
|
||||
"sensors.TouchSensor.isTouched|block": "`icons.touchSensor` %sensor|is touched",
|
||||
"sensors.TouchSensor.onEvent|block": "on `icons.touchSensor` %sensor|%event",
|
||||
"sensors.UltraSonicSensor.distance|block": "`icons.ultrasonicSensor` %sensor|distance",
|
||||
"sensors.UltraSonicSensor.on|block": "on `icons.ultrasonicSensor` %sensor|%event",
|
||||
"sensors.UltraSonicSensor.wait|block": "wait `icons.ultrasonicSensor` %sensor|for %event",
|
||||
@ -104,10 +99,6 @@
|
||||
"sensors.remoteButtonCenter|block": "center",
|
||||
"sensors.remoteButtonTopLeft|block": "top-left",
|
||||
"sensors.remoteButtonTopRight|block": "top-right",
|
||||
"sensors.touchSensor1|block": "1",
|
||||
"sensors.touchSensor2|block": "2",
|
||||
"sensors.touchSensor3|block": "3",
|
||||
"sensors.touchSensor4|block": "4",
|
||||
"sensors.ultrasonic1|block": "1",
|
||||
"sensors.ultrasonic2|block": "2",
|
||||
"sensors.ultrasonic3|block": "3",
|
||||
@ -132,6 +123,5 @@
|
||||
"{id:group}Motors": "Motors",
|
||||
"{id:group}Remote Infrared Beacon": "Remote Infrared Beacon",
|
||||
"{id:group}Screen": "Screen",
|
||||
"{id:group}Touch Sensor": "Touch Sensor",
|
||||
"{id:group}Ultrasonic Sensor": "Ultrasonic Sensor"
|
||||
}
|
@ -22,7 +22,6 @@
|
||||
"color.ts",
|
||||
"gyro.ts",
|
||||
"ultrasonic.ts",
|
||||
"touch.ts",
|
||||
"shims.d.ts",
|
||||
"enums.d.ts",
|
||||
"dal.d.ts",
|
||||
|
@ -8,7 +8,8 @@
|
||||
"dependencies": {
|
||||
"base": "file:../base",
|
||||
"core": "file:../core",
|
||||
"music": "file:../music"
|
||||
"music": "file:../music",
|
||||
"touch-sensor": "file:../touch-sensor"
|
||||
},
|
||||
"public": true
|
||||
}
|
||||
|
3
libs/touch-sensor/README.md
Normal file
3
libs/touch-sensor/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Touch sensor
|
||||
|
||||
The library to interact with the Touch Sensor.
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"TouchSensorEvent": "Touch sensor interactions",
|
||||
"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.wasPressed": "Check if touch sensor is touched since it was last checked."
|
||||
}
|
14
libs/touch-sensor/_locales/touch-sensor-strings.json
Normal file
14
libs/touch-sensor/_locales/touch-sensor-strings.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"TouchSensorEvent.Bumped|block": "bumped",
|
||||
"TouchSensorEvent.Pressed|block": "pressed",
|
||||
"TouchSensorEvent.Released|block": "released",
|
||||
"sensors.TouchSensor.isPressed|block": "`icons.touchSensor` %sensor|is pressed",
|
||||
"sensors.TouchSensor.onEvent|block": "on `icons.touchSensor` %sensor|%event",
|
||||
"sensors.TouchSensor.wasPressed|block": "`icons.touchSensor` %sensor|was pressed",
|
||||
"sensors.touchSensor1|block": "1",
|
||||
"sensors.touchSensor2|block": "2",
|
||||
"sensors.touchSensor3|block": "3",
|
||||
"sensors.touchSensor4|block": "4",
|
||||
"{id:category}Sensors": "Sensors",
|
||||
"{id:group}Touch Sensor": "Touch Sensor"
|
||||
}
|
15
libs/touch-sensor/pxt.json
Normal file
15
libs/touch-sensor/pxt.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "touch-sensor",
|
||||
"description": "Touch Sensor support",
|
||||
"files": [
|
||||
"README.md",
|
||||
"touch.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"core": "file:../core"
|
||||
}
|
||||
}
|
8
libs/touch-sensor/test.ts
Normal file
8
libs/touch-sensor/test.ts
Normal file
@ -0,0 +1,8 @@
|
||||
sensors.touchSensor1.onEvent(TouchSensorEvent.Pressed, function () {
|
||||
})
|
||||
sensors.touchSensor2.onEvent(TouchSensorEvent.Bumped, function () {
|
||||
})
|
||||
sensors.touchSensor3.onEvent(TouchSensorEvent.Released, function () {
|
||||
})
|
||||
sensors.touchSensor4.isPressed();
|
||||
sensors.touchSensor4.wasPressed();
|
@ -41,7 +41,7 @@ namespace sensors {
|
||||
* @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
|
||||
//% help=input/touch-sensor/on-event
|
||||
//% blockId=touchEvent block="on `icons.touchSensor` %sensor|%event"
|
||||
//% parts="touch"
|
||||
//% blockNamespace=sensors
|
||||
@ -55,16 +55,31 @@ namespace sensors {
|
||||
* Check if touch sensor is touched.
|
||||
* @param sensor the port to query the request
|
||||
*/
|
||||
//% help=input/touch/is-touched
|
||||
//% block="`icons.touchSensor` %sensor|is touched"
|
||||
//% blockId=touchIsTouched
|
||||
//% help=input/touch-sensor/is-pressed
|
||||
//% block="`icons.touchSensor` %sensor|is pressed"
|
||||
//% blockId=touchIsPressed
|
||||
//% parts="touch"
|
||||
//% blockNamespace=sensors
|
||||
//% weight=81 blockGap=8
|
||||
//% group="Touch Sensor"
|
||||
isTouched() {
|
||||
isPressed() {
|
||||
return this.button.isPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if touch sensor is touched since it was last checked.
|
||||
* @param sensor the port to query the request
|
||||
*/
|
||||
//% help=input/touch-sensor/was-pressed
|
||||
//% block="`icons.touchSensor` %sensor|was pressed"
|
||||
//% blockId=touchWasPressed
|
||||
//% parts="touch"
|
||||
//% blockNamespace=sensors
|
||||
//% weight=81 blockGap=8
|
||||
//% group="Touch Sensor"
|
||||
wasPressed() {
|
||||
return this.button.wasPressed();
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed block="1" weight=95 fixedInstance
|
@ -10,6 +10,7 @@
|
||||
"libs/base",
|
||||
"libs/core",
|
||||
"libs/music",
|
||||
"libs/touch-sensor",
|
||||
"libs/ev3"
|
||||
],
|
||||
"simulator": {
|
||||
|
Loading…
Reference in New Issue
Block a user