renaming IR events

This commit is contained in:
Peli de Halleux 2017-10-26 20:20:24 -07:00
parent 0e1a3b7e6b
commit 59ce4338d3
4 changed files with 25 additions and 25 deletions

View File

@ -29,8 +29,8 @@
"input.ColorSensor.reflectedLight": "Get current reflected light value from the color sensor.", "input.ColorSensor.reflectedLight": "Get current reflected light value from the color sensor.",
"input.GyroSensor.angle": "Get the current angle from the gyroscope.", "input.GyroSensor.angle": "Get the current angle from the gyroscope.",
"input.GyroSensor.rate": "Get the current rotation rate from the gyroscope.", "input.GyroSensor.rate": "Get the current rotation rate from the gyroscope.",
"input.IrSensor.distance": "Get the distance measured by the infrared sensor.", "input.InfraredSensor.proximity": "Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)",
"input.IrSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.", "input.InfraredSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.",
"input.TouchSensor.isTouched": "Check if touch sensor is touched.", "input.TouchSensor.isTouched": "Check if touch sensor is touched.",
"input.TouchSensor.onEvent": "Do something when a touch sensor is touched...", "input.TouchSensor.onEvent": "Do something when a touch sensor is touched...",
"input.TouchSensor.onEvent|param|body": "code to run when the event is raised", "input.TouchSensor.onEvent|param|body": "code to run when the event is raised",

View File

@ -30,8 +30,8 @@
"input.ColorSensor.reflectedLight|block": "%color| reflected light", "input.ColorSensor.reflectedLight|block": "%color| reflected light",
"input.GyroSensor.angle|block": "%sensor|angle", "input.GyroSensor.angle|block": "%sensor|angle",
"input.GyroSensor.rate|block": "%sensor|rotation rate", "input.GyroSensor.rate|block": "%sensor|rotation rate",
"input.IrSensor.distance|block": "%infrared|distance", "input.InfraredSensor.proximity|block": "%infrared|proximity",
"input.IrSensor.remoteCommand|block": "%infrared|remote command", "input.InfraredSensor.remoteCommand|block": "%infrared|remote command",
"input.TouchSensor.isTouched|block": "%sensor|is touched", "input.TouchSensor.isTouched|block": "%sensor|is touched",
"input.TouchSensor.onEvent|block": "on %sensor|%event", "input.TouchSensor.onEvent|block": "on %sensor|%event",
"input.UltraSonicSensor.distance|block": "%sensor|distance", "input.UltraSonicSensor.distance|block": "%sensor|distance",

View File

@ -42,7 +42,7 @@ namespace input {
let buttons: Button[] let buttons: Button[]
function create(ir: IrSensor) { function create(ir: InfraredSensor) {
// it's created by referencing it // it's created by referencing it
} }
@ -54,10 +54,10 @@ namespace input {
} }
// make sure sensors are up // make sure sensors are up
create(ir1) create(infrared1)
create(ir2) create(infrared2)
create(ir3) create(infrared3)
create(ir4) create(infrared4)
} }
let num = -1 let num = -1
@ -69,8 +69,8 @@ namespace input {
return buttons[num] return buttons[num]
} }
//% fixedInstance //% fixedInstances
export class IrSensor extends internal.UartSensor { export class InfraredSensor extends internal.UartSensor {
private channel: IrRemoteChannel private channel: IrRemoteChannel
constructor(port: number) { constructor(port: number) {
@ -110,17 +110,17 @@ namespace input {
} }
/** /**
* Get the distance measured by the infrared sensor. * Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)
* @param ir the infrared sensor * @param ir the infrared sensor
*/ */
//% help=input/infrared/distance //% help=input/infrared/proximity
//% block="%infrared|distance" //% block="%infrared|proximity"
//% blockId=infraredGetDistance //% blockId=infraredGetProximity
//% parts="infrared" //% parts="infrared"
//% blockNamespace=input //% blockNamespace=input
//% weight=65 blockGap=8 //% weight=65 blockGap=8
//% group="Infrared Sensor" //% group="Infrared Sensor"
distance() { proximity() {
this.setMode(IrSensorMode.Proximity) this.setMode(IrSensorMode.Proximity)
return this.getNumber(NumberFormat.UInt8LE, 0) return this.getNumber(NumberFormat.UInt8LE, 0)
} }
@ -148,17 +148,17 @@ namespace input {
} }
} }
//% whenUsed //% fixedInstance whenUsed
export const ir1: IrSensor = new IrSensor(1) export const infrared1: InfraredSensor = new InfraredSensor(1)
//% whenUsed //% fixedInstance whenUsed
export const ir2: IrSensor = new IrSensor(2) export const infrared2: InfraredSensor = new InfraredSensor(2)
//% whenUsed //% fixedInstance whenUsed
export const ir3: IrSensor = new IrSensor(3) export const infrared3: InfraredSensor = new InfraredSensor(3)
//% whenUsed //% fixedInstance whenUsed
export const ir4: IrSensor = new IrSensor(4) export const infrared4: InfraredSensor = new InfraredSensor(4)
/** /**
* Remote top-left button. * Remote top-left button.

View File

@ -1,5 +1,5 @@
//% color="#B4009E" weight=98 icon="\uf192" //% color="#B4009E" weight=98 icon="\uf192"
//% groups='["Touch Sensor", "Gyro Sensor", "Color Sensor", "Ultrasonic Sensor", "Infrared Sensor", "Remote", "Brick"]' //% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Infrared Sensor", "Remote", "Brick", "Gyro Sensor"]'
namespace input { namespace input {
} }