From a4164470d8edc8d8b5470d47ee2f7a6a596cc3e8 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 10 Jan 2018 22:29:35 -0800 Subject: [PATCH] updated api to align with labview --- libs/core/_locales/core-strings.json | 1 + libs/core/output.ts | 6 ++++-- .../_locales/gyro-sensor-jsdoc-strings.json | 4 ++-- .../_locales/gyro-sensor-strings.json | 4 ++-- libs/gyro-sensor/gyro.ts | 16 +++++++++------- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index a0861b81..71e3ba76 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -55,6 +55,7 @@ "motors.Motor.speed|block": "%motor|speed", "motors.Motor.tacho|block": "%motor|tacho", "motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready", + "motors.MotorBase.reset|block": "%motors|reset", "motors.MotorBase.setBrake|block": "set %motor|brake %brake", "motors.MotorBase.setReversed|block": "set %motor|reversed %reversed", "motors.MotorBase.setSpeed|block": "set %motor|speed to %speed=motorSpeedPicker|%", diff --git a/libs/core/output.ts b/libs/core/output.ts index ab55eacb..dc903dad 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -111,7 +111,7 @@ namespace motors { * Stops all motors */ //% blockId=motorStopAll block="stop all motors" - //% weight=5 + //% weight=1 //% group="Move" export function stopAllMotors() { const b = mkCmd(Output.ALL, DAL.opOutputStop, 0) @@ -198,7 +198,9 @@ namespace motors { /** * Resets the motor(s). */ - //% + //% weight=5 + //% group="Move" + //% blockId=motorReset block="%motors|reset" reset() { this.init(); reset(this._port); diff --git a/libs/gyro-sensor/_locales/gyro-sensor-jsdoc-strings.json b/libs/gyro-sensor/_locales/gyro-sensor-jsdoc-strings.json index c8d334f5..f123fd23 100644 --- a/libs/gyro-sensor/_locales/gyro-sensor-jsdoc-strings.json +++ b/libs/gyro-sensor/_locales/gyro-sensor-jsdoc-strings.json @@ -1,5 +1,5 @@ { "sensors.GyroSensor.angle": "Get the current angle from the gyroscope.", - "sensors.GyroSensor.calibrate": "Forces a calibration of the gyro. Must be called when the sensor is completely still.", - "sensors.GyroSensor.rotationRate": "Get the current rotation rate from the gyroscope." + "sensors.GyroSensor.rate": "Get the current rotation rate from the gyroscope.", + "sensors.GyroSensor.reset": "Forces a calibration of the gyro. Must be called when the sensor is completely still." } \ No newline at end of file diff --git a/libs/gyro-sensor/_locales/gyro-sensor-strings.json b/libs/gyro-sensor/_locales/gyro-sensor-strings.json index 127b6e61..cfd0d42f 100644 --- a/libs/gyro-sensor/_locales/gyro-sensor-strings.json +++ b/libs/gyro-sensor/_locales/gyro-sensor-strings.json @@ -1,7 +1,7 @@ { "sensors.GyroSensor.angle|block": "%sensor|angle", - "sensors.GyroSensor.calibrate|block": "%sensor|calibrate", - "sensors.GyroSensor.rotationRate|block": "%sensor|rotation rate", + "sensors.GyroSensor.rate|block": "%sensor|rate", + "sensors.GyroSensor.reset|block": "%sensor|reset", "sensors.gyro1|block": "gyro 1", "sensors.gyro2|block": "gyro 2", "sensors.gyro3|block": "gyro 3", diff --git a/libs/gyro-sensor/gyro.ts b/libs/gyro-sensor/gyro.ts index 889f643d..11e46e26 100644 --- a/libs/gyro-sensor/gyro.ts +++ b/libs/gyro-sensor/gyro.ts @@ -45,15 +45,15 @@ namespace sensors { * Get the current rotation rate from the gyroscope. * @param sensor the gyroscope to query the request */ - //% help=input/gyro/rotation-rate - //% block="%sensor|rotation rate" + //% help=input/gyro/rate + //% block="%sensor|rate" //% blockId=gyroGetRate //% parts="gyroscope" //% blockNamespace=sensors //% sensor.fieldEditor="ports" //% weight=65 blockGap=8 //% group="Gyro Sensor" - rotationRate(): number { + rate(): number { if (this.calibrating) pauseUntil(() => !this.calibrating, 2000); @@ -65,14 +65,14 @@ namespace sensors { * Forces a calibration of the gyro. Must be called when the sensor is completely still. */ //% help=input/gyro/calibrate - //% block="%sensor|calibrate" - //% blockId=gyroCalibrate + //% block="%sensor|reset" + //% blockId=gyroReset //% parts="gyroscope" //% blockNamespace=sensors //% sensor.fieldEditor="ports" //% weight=50 blockGap=8 //% group="Gyro Sensor" - calibrate(): void { + reset(): void { if (this.calibrating) return; // already in calibration mode this.calibrating = true; @@ -90,7 +90,9 @@ namespace sensors { this.setMode(GyroSensorMode.Angle); else this.setMode(GyroSensorMode.Rate); - this.calibrating = false; + // give it more time to settle + loops.pause(500); + this.calibrating = false; } }