From 59ce4338d33e22c531af251690cba060d4372fe9 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 26 Oct 2017 20:20:24 -0700 Subject: [PATCH] renaming IR events --- libs/core/_locales/core-jsdoc-strings.json | 4 +-- libs/core/_locales/core-strings.json | 4 +-- libs/core/ir.ts | 40 +++++++++++----------- libs/core/ns.ts | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 1f6d96c3..3710fd41 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -29,8 +29,8 @@ "input.ColorSensor.reflectedLight": "Get current reflected light value from the color sensor.", "input.GyroSensor.angle": "Get the current angle 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.IrSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.", + "input.InfraredSensor.proximity": "Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)", + "input.InfraredSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.", "input.TouchSensor.isTouched": "Check if 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", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 7bb52492..a0cec4db 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -30,8 +30,8 @@ "input.ColorSensor.reflectedLight|block": "%color| reflected light", "input.GyroSensor.angle|block": "%sensor|angle", "input.GyroSensor.rate|block": "%sensor|rotation rate", - "input.IrSensor.distance|block": "%infrared|distance", - "input.IrSensor.remoteCommand|block": "%infrared|remote command", + "input.InfraredSensor.proximity|block": "%infrared|proximity", + "input.InfraredSensor.remoteCommand|block": "%infrared|remote command", "input.TouchSensor.isTouched|block": "%sensor|is touched", "input.TouchSensor.onEvent|block": "on %sensor|%event", "input.UltraSonicSensor.distance|block": "%sensor|distance", diff --git a/libs/core/ir.ts b/libs/core/ir.ts index 2ceaed5a..5e2849fa 100644 --- a/libs/core/ir.ts +++ b/libs/core/ir.ts @@ -42,7 +42,7 @@ namespace input { let buttons: Button[] - function create(ir: IrSensor) { + function create(ir: InfraredSensor) { // it's created by referencing it } @@ -54,10 +54,10 @@ namespace input { } // make sure sensors are up - create(ir1) - create(ir2) - create(ir3) - create(ir4) + create(infrared1) + create(infrared2) + create(infrared3) + create(infrared4) } let num = -1 @@ -69,8 +69,8 @@ namespace input { return buttons[num] } - //% fixedInstance - export class IrSensor extends internal.UartSensor { + //% fixedInstances + export class InfraredSensor extends internal.UartSensor { private channel: IrRemoteChannel 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 */ - //% help=input/infrared/distance - //% block="%infrared|distance" - //% blockId=infraredGetDistance + //% help=input/infrared/proximity + //% block="%infrared|proximity" + //% blockId=infraredGetProximity //% parts="infrared" //% blockNamespace=input //% weight=65 blockGap=8 //% group="Infrared Sensor" - distance() { + proximity() { this.setMode(IrSensorMode.Proximity) return this.getNumber(NumberFormat.UInt8LE, 0) } @@ -148,17 +148,17 @@ namespace input { } } - //% whenUsed - export const ir1: IrSensor = new IrSensor(1) + //% fixedInstance whenUsed + export const infrared1: InfraredSensor = new InfraredSensor(1) - //% whenUsed - export const ir2: IrSensor = new IrSensor(2) + //% fixedInstance whenUsed + export const infrared2: InfraredSensor = new InfraredSensor(2) - //% whenUsed - export const ir3: IrSensor = new IrSensor(3) + //% fixedInstance whenUsed + export const infrared3: InfraredSensor = new InfraredSensor(3) - //% whenUsed - export const ir4: IrSensor = new IrSensor(4) + //% fixedInstance whenUsed + export const infrared4: InfraredSensor = new InfraredSensor(4) /** * Remote top-left button. diff --git a/libs/core/ns.ts b/libs/core/ns.ts index 4902e556..14238015 100644 --- a/libs/core/ns.ts +++ b/libs/core/ns.ts @@ -1,5 +1,5 @@ //% 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 { }