From 085ab0844b23b00f7f5591a10ee4a801a73d0f2c Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 6 Dec 2017 22:41:51 -0800 Subject: [PATCH] rename "power" to "set speed" for consistency --- libs/core/_locales/core-jsdoc-strings.json | 4 ++-- libs/core/_locales/core-strings.json | 2 +- libs/core/output.ts | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index d59f4270..e546c150 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -55,12 +55,12 @@ "motors.Motor.move": "Moves the motor by a number of degrees", "motors.Motor.move|param|angle": "the degrees to rotate, eg: 360", "motors.Motor.move|param|power": "the power from ``100`` full forward to ``-100`` full backward, eg: 50", - "motors.Motor.power": "Sets the motor power level from ``-100`` to ``100``.", - "motors.Motor.power|param|power": "the power from ``100`` full forward to ``-100`` full backward, eg: 50", "motors.Motor.reset": "Resets the motor.", "motors.Motor.setBrake": "Sets the automatic brake on or off when the motor is off", "motors.Motor.setBrake|param|brake": "a value indicating if the motor should break when off", "motors.Motor.setReversed": "Reverses the motor polarity", + "motors.Motor.setSpeed": "Sets the motor speed level from ``-100`` to ``100``.", + "motors.Motor.setSpeed|param|speed": "the power from ``100`` full forward to ``-100`` full backward, eg: 50", "motors.Motor.speed": "Gets motor actual speed.", "motors.Motor.stop": "Stops the motor", "motors.Motor.tachoCount": "Gets motor tacho count.", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 2f10e924..76ee79a4 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -37,9 +37,9 @@ "control|block": "control", "motors.Motor.count|block": "`icons.motorLarge` %motor|count", "motors.Motor.move|block": "move `icons.motorLarge` %motor|by %angle|degrees at %power|%", - "motors.Motor.power|block": "power `icons.motorLarge` %motor|to %power|%", "motors.Motor.setBrake|block": "set `icons.motorLarge` %motor|brake %brake", "motors.Motor.setReversed|block": "set `icons.motorLarge` %motor|reversed %reversed", + "motors.Motor.setSpeed|block": "set speed `icons.motorLarge` %motor|to %speed|%", "motors.Motor.speed|block": "`icons.motorLarge` %motor|speed", "motors.Motor.stop|block": "stop `icons.motorLarge` %motor", "motors.Motor.tachoCount|block": "`icons.motorLarge` %motor|tacho count", diff --git a/libs/core/output.ts b/libs/core/output.ts index 209e14d4..18fdf21e 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -87,21 +87,21 @@ namespace motors { } /** - * Sets the motor power level from ``-100`` to ``100``. + * Sets the motor speed level from ``-100`` to ``100``. * @param motor the output connection that the motor is connected to - * @param power the power from ``100`` full forward to ``-100`` full backward, eg: 50 + * @param speed the power from ``100`` full forward to ``-100`` full backward, eg: 50 */ - //% blockId=motorSetPower block="power `icons.motorLarge` %motor|to %power|%" + //% blockId=motorSetSpeed block="set speed `icons.motorLarge` %motor|to %speed|%" //% weight=99 group="Motors" blockGap=8 //% power.min=-100 power.max=100 - power(power: number) { - power = Math.clamp(-100, 100, power >> 0); + setSpeed(speed: number) { + speed = Math.clamp(-100, 100, speed >> 0); // per LEGO: call it power, use speed const b = mkCmd(this.port, DAL.opOutputSpeed, 1) - b.setNumber(NumberFormat.Int8LE, 2, power) + b.setNumber(NumberFormat.Int8LE, 2, speed) writePWM(b) - if (power) { + if (speed) { const b = mkCmd(this.port, DAL.opOutputStart, 0) writePWM(b); } else { @@ -141,7 +141,7 @@ namespace motors { const b = mkCmd(this.port, DAL.opOutputStop, 1) b.setNumber(NumberFormat.UInt8LE, 2, this.brake ? 1 : 0) writePWM(b); - } + } /** * Sets the automatic brake on or off when the motor is off