From c85c68ab68ac17c21e37e19be039bccc8f9b38d7 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 24 Oct 2017 15:22:07 -0700 Subject: [PATCH] fixing color / gyro --- libs/core/_locales/core-jsdoc-strings.json | 6 +++--- libs/core/_locales/core-strings.json | 12 +++++++++--- libs/core/color.ts | 9 ++++++--- libs/core/gyro.ts | 14 ++++++++------ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 91ef5c7f..72ee4d8c 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -23,9 +23,9 @@ "input.Button.onEvent": "Do something when a button or sensor is clicked, double clicked, etc...", "input.Button.onEvent|param|body": "code to run when the event is raised", "input.Button.wasPressed": "See if the button was pressed again since the last time you checked.", - "input.ColorSensor.getAmbientLight": "Get current ambient light value from the color sensor.", - "input.ColorSensor.getColor": "Get the current color from the color sensor.", - "input.ColorSensor.getReflectedLight": "Get current reflected light value from the color sensor.", + "input.ColorSensor.ambientLight": "Get current ambient light value from the color sensor.", + "input.ColorSensor.color": "Get the current color 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.rate": "Get the current rotation rate from the gyroscope.", "input.IrSensor.distance": "Get the distance measured by the infrared sensor.", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 34e323a9..dd67b605 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -18,9 +18,9 @@ "input.Button.isPressed|block": "%button|is pressed", "input.Button.onEvent|block": "on %button|%event", "input.Button.wasPressed|block": "%button|was pressed", - "input.ColorSensor.getAmbientLight|block": "%color| ambient light", - "input.ColorSensor.getColor|block": "%color| color", - "input.ColorSensor.getReflectedLight|block": "%color| reflected light", + "input.ColorSensor.ambientLight|block": "%color| ambient light", + "input.ColorSensor.color|block": "%color| color", + "input.ColorSensor.reflectedLight|block": "%color| reflected light", "input.GyroSensor.angle|block": "%color|angle", "input.GyroSensor.rate|block": "%color|rotation rate", "input.IrSensor.distance|block": "%infrared|distance", @@ -34,6 +34,10 @@ "input.color2|block": "color sensor 2", "input.color3|block": "color sensor 3", "input.color4|block": "color sensor 4", + "input.gyro1|block": "gyroscope 1", + "input.gyro2|block": "gyroscope 2", + "input.gyro3|block": "gyroscope 3", + "input.gyro4|block": "gyroscope 4", "input.remoteBottomLeft|block": "remote bottom-left", "input.remoteBottomRight|block": "remote bottom-right", "input.remoteCenter|block": "remote center", @@ -61,6 +65,8 @@ "{id:category}Output": "Output", "{id:category}Screen": "Screen", "{id:category}Serial": "Serial", + "{id:group}Color Sensor": "Color Sensor", + "{id:group}Gyroscope": "Gyroscope", "{id:group}Lights": "Lights", "{id:group}Motors": "Motors", "{id:group}Screen": "Screen" diff --git a/libs/core/color.ts b/libs/core/color.ts index 49ef569c..20e1f2c9 100644 --- a/libs/core/color.ts +++ b/libs/core/color.ts @@ -45,7 +45,8 @@ namespace input { //% parts="colorsensor" //% blockNamespace=input //% weight=65 blockGap=8 - getAmbientLight() { + //% group="Color Sensor" + ambientLight() { this.setMode(ColorSensorMode.Ambient) return this.getNumber(NumberFormat.UInt8LE, 0) } @@ -60,7 +61,8 @@ namespace input { //% parts="colorsensor" //% blockNamespace=input //% weight=64 blockGap=8 - getReflectedLight(): number { + //% group="Color Sensor" + reflectedLight(): number { this.setMode(ColorSensorMode.Reflect) return this.getNumber(NumberFormat.UInt8LE, 0) } @@ -75,7 +77,8 @@ namespace input { //% parts="colorsensor" //% blockNamespace=input //% weight=66 blockGap=8 - getColor(): ColorSensorColor { + //% group="Color Sensor" + color(): ColorSensorColor { this.setMode(ColorSensorMode.Color) return this.getNumber(NumberFormat.UInt8LE, 0) } diff --git a/libs/core/gyro.ts b/libs/core/gyro.ts index 61992e6c..e99c5dd5 100644 --- a/libs/core/gyro.ts +++ b/libs/core/gyro.ts @@ -5,7 +5,7 @@ const enum GyroSensorMode { } namespace input { - //% fixedInstance + //% fixedInstances export class GyroSensor extends internal.UartSensor { constructor(port: number) { super(port) @@ -28,7 +28,8 @@ namespace input { //% blockId=gyroGetAngle //% parts="gyroscope" //% blockNamespace=input - //% weight=65 blockGap=8 + //% weight=65 blockGap=8 + //% group="Gyroscope" angle() { this.setMode(GyroSensorMode.Angle) return this.getNumber(NumberFormat.Int16LE, 0) @@ -44,21 +45,22 @@ namespace input { //% parts="gyroscope" //% blockNamespace=input //% weight=65 blockGap=8 + //% group="Gyroscope" rate() { this.setMode(GyroSensorMode.Rate) return this.getNumber(NumberFormat.Int16LE, 0) } } - //% whenUsed + //% fixedInstance whenUsed block="gyroscope 1" export const gyro1: GyroSensor = new GyroSensor(1) - //% whenUsed + //% fixedInstance whenUsed block="gyroscope 2" export const gyro2: GyroSensor = new GyroSensor(2) - //% whenUsed + //% fixedInstance whenUsed block="gyroscope 3" export const gyro3: GyroSensor = new GyroSensor(3) - //% whenUsed + //% fixedInstance whenUsed block="gyroscope 4" export const gyro4: GyroSensor = new GyroSensor(4) }