moving IR as well

This commit is contained in:
Peli de Halleux 2017-11-30 09:53:43 -08:00
parent 32f524ddd8
commit 34a5aeb7d2
12 changed files with 66 additions and 44 deletions

View File

@ -70,20 +70,6 @@
"screen.unpackPNG": "Decompresses a 1-bit gray scale PNG image to image format.",
"sensors.GyroSensor.angle": "Get the current angle from the gyroscope.",
"sensors.GyroSensor.rate": "Get the current rotation rate from the gyroscope.",
"sensors.InfraredSensor.on": "Registers code to run when an object is getting near.",
"sensors.InfraredSensor.on|param|handler": "the code to run when detected",
"sensors.InfraredSensor.proximity": "Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)",
"sensors.InfraredSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.",
"sensors.InfraredSensor.waitUntil": "Waits for the event to occur",
"sensors.RemoteInfraredBeaconButton.isPressed": "Check if a remote button is currently pressed or not.",
"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.remoteButtonBottomLeft": "Remote bottom-left button.",
"sensors.remoteButtonBottomRight": "Remote bottom-right button.",
"sensors.remoteButtonCenter": "Remote beacon (center) button.",
"sensors.remoteButtonTopLeft": "Remote top-left button.",
"sensors.remoteButtonTopRight": "Remote top-right button.",
"serial": "Reading and writing data over a serial connection.",
"serial.writeDmesg": "Send DMESG debug buffer over serial."
}

View File

@ -2,8 +2,6 @@
"ButtonEvent.Click|block": "click",
"ButtonEvent.Down|block": "down",
"ButtonEvent.Up|block": "up",
"InfraredSensorEvent.ObjectDetected|block": "object detected",
"InfraredSensorEvent.ObjectNear|block": "object near",
"LightsPattern.GreenFlash|block": "Flashing Green",
"LightsPattern.GreenPulse|block": "Pulsing Green",
"LightsPattern.Green|block": "Green",
@ -58,27 +56,10 @@
"screen|block": "screen",
"sensors.GyroSensor.angle|block": "`icons.gyroSensor` %sensor|angle",
"sensors.GyroSensor.rate|block": "`icons.gyroSensor` %sensor|rotation rate",
"sensors.InfraredSensor.on|block": "on `icons.infraredSensor` %sensor|%event",
"sensors.InfraredSensor.proximity|block": "`icons.infraredSensor` %infrared|proximity",
"sensors.InfraredSensor.remoteCommand|block": "`icons.infraredSensor` %infrared|remote command",
"sensors.InfraredSensor.waitUntil|block": "wait until `icons.infraredSensor` %sensor| %event",
"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.gyro1|block": "1",
"sensors.gyro2|block": "2",
"sensors.gyro3|block": "3",
"sensors.gyro4|block": "4",
"sensors.infraredSensor1|block": "1",
"sensors.infraredSensor2|block": "2",
"sensors.infraredSensor3|block": "3",
"sensors.infraredSensor4|block": "4",
"sensors.remoteButtonBottomLeft|block": "bottom-left",
"sensors.remoteButtonBottomRight|block": "bottom-right",
"sensors.remoteButtonCenter|block": "center",
"sensors.remoteButtonTopLeft|block": "top-left",
"sensors.remoteButtonTopRight|block": "top-right",
"sensors|block": "sensors",
"serial|block": "serial",
"{id:category}Brick": "Brick",
"{id:category}Control": "Control",
@ -92,9 +73,7 @@
"{id:category}Serial": "Serial",
"{id:group}Buttons": "Buttons",
"{id:group}Gyro Sensor": "Gyro Sensor",
"{id:group}Infrared Sensor": "Infrared Sensor",
"{id:group}Light": "Light",
"{id:group}Motors": "Motors",
"{id:group}Remote Infrared Beacon": "Remote Infrared Beacon",
"{id:group}Screen": "Screen"
}

View File

@ -18,7 +18,6 @@
"output.ts",
"core.ts",
"input.ts",
"ir.ts",
"gyro.ts",
"shims.d.ts",
"enums.d.ts",

View File

@ -11,7 +11,8 @@
"music": "file:../music",
"color-sensor": "file:../color-sensor",
"touch-sensor": "file:../touch-sensor",
"ultrasonic-sensor": "file:../ultrasonic-sensor"
"ultrasonic-sensor": "file:../ultrasonic-sensor",
"infrared-sensor": "file:../infrared-sensor"
},
"public": true
}

View File

@ -0,0 +1,3 @@
# Infrared sensor
The library to interact with the Infrared Sensor.

View File

@ -0,0 +1,16 @@
{
"sensors.InfraredSensor.onEvent": "Registers code to run when an object is getting near.",
"sensors.InfraredSensor.onEvent|param|handler": "the code to run when detected",
"sensors.InfraredSensor.proximity": "Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)",
"sensors.InfraredSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.",
"sensors.InfraredSensor.waitUntil": "Waits for the event to occur",
"sensors.RemoteInfraredBeaconButton.isPressed": "Check if a remote button is currently pressed or not.",
"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.remoteButtonBottomLeft": "Remote bottom-left button.",
"sensors.remoteButtonBottomRight": "Remote bottom-right button.",
"sensors.remoteButtonCenter": "Remote beacon (center) button.",
"sensors.remoteButtonTopLeft": "Remote top-left button.",
"sensors.remoteButtonTopRight": "Remote top-right button."
}

View File

@ -0,0 +1,24 @@
{
"InfraredSensorEvent.ObjectDetected|block": "object detected",
"InfraredSensorEvent.ObjectNear|block": "object near",
"sensors.InfraredSensor.onEvent|block": "on `icons.infraredSensor` %sensor|%event",
"sensors.InfraredSensor.proximity|block": "`icons.infraredSensor` %infrared|proximity",
"sensors.InfraredSensor.remoteCommand|block": "`icons.infraredSensor` %infrared|remote command",
"sensors.InfraredSensor.waitUntil|block": "wait until `icons.infraredSensor` %sensor| %event",
"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.infraredSensor1|block": "1",
"sensors.infraredSensor2|block": "2",
"sensors.infraredSensor3|block": "3",
"sensors.infraredSensor4|block": "4",
"sensors.remoteButtonBottomLeft|block": "bottom-left",
"sensors.remoteButtonBottomRight|block": "bottom-right",
"sensors.remoteButtonCenter|block": "center",
"sensors.remoteButtonTopLeft|block": "top-left",
"sensors.remoteButtonTopRight|block": "top-right",
"sensors|block": "sensors",
"{id:category}Sensors": "Sensors",
"{id:group}Infrared Sensor": "Infrared Sensor",
"{id:group}Remote Infrared Beacon": "Remote Infrared Beacon"
}

View File

@ -199,10 +199,8 @@ namespace sensors {
//% blockNamespace=sensors
//% weight=100 blockGap=8
//% group="Infrared Sensor"
on(event: InfraredSensorEvent, handler: () => void) {
onEvent(event: InfraredSensorEvent, handler: () => void) {
control.onEvent(this._id, InfraredSensorEvent.ObjectNear, handler);
if ( this.proximity() == InfraredSensorEvent.ObjectNear)
control.runInBackground(handler);
}
/**
@ -230,7 +228,7 @@ namespace sensors {
//% blockNamespace=sensors
//% weight=65 blockGap=8
//% group="Infrared Sensor"
proximity() {
proximity(): number {
this._setMode(IrSensorMode.Proximity)
return this.getNumber(NumberFormat.UInt8LE, 0)
}
@ -246,7 +244,7 @@ namespace sensors {
//% blockNamespace=sensors
//% weight=65 blockGap=8
//% group="Infrared Sensor"
remoteCommand() {
remoteCommand(): number {
this._setMode(IrSensorMode.RemoteControl)
return this.getNumber(NumberFormat.UInt8LE, this.channel)
}

View File

@ -0,0 +1,15 @@
{
"name": "infrared-sensor",
"description": "Infrared Sensor support",
"files": [
"README.md",
"ir.ts"
],
"testFiles": [
"test.ts"
],
"public": true,
"dependencies": {
"core": "file:../core"
}
}

View File

View File

@ -1,3 +1,3 @@
# Touch sensor
# Ultrasonic sensor
The library to interact with the Touch Sensor.
The library to interact with the Ultrasonic Sensor.

View File

@ -13,6 +13,7 @@
"libs/color-sensor",
"libs/touch-sensor",
"libs/ultrasonic-sensor",
"libs/infrared-sensor",
"libs/ev3"
],
"simulator": {