rename "power" to "set speed" for consistency
This commit is contained in:
parent
4ad229cb37
commit
085ab0844b
@ -55,12 +55,12 @@
|
|||||||
"motors.Motor.move": "Moves the motor by a number of degrees",
|
"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|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.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.reset": "Resets the motor.",
|
||||||
"motors.Motor.setBrake": "Sets the automatic brake on or off when the motor is off",
|
"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.setBrake|param|brake": "a value indicating if the motor should break when off",
|
||||||
"motors.Motor.setReversed": "Reverses the motor polarity",
|
"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.speed": "Gets motor actual speed.",
|
||||||
"motors.Motor.stop": "Stops the motor",
|
"motors.Motor.stop": "Stops the motor",
|
||||||
"motors.Motor.tachoCount": "Gets motor tacho count.",
|
"motors.Motor.tachoCount": "Gets motor tacho count.",
|
||||||
|
@ -37,9 +37,9 @@
|
|||||||
"control|block": "control",
|
"control|block": "control",
|
||||||
"motors.Motor.count|block": "`icons.motorLarge` %motor|count",
|
"motors.Motor.count|block": "`icons.motorLarge` %motor|count",
|
||||||
"motors.Motor.move|block": "move `icons.motorLarge` %motor|by %angle|degrees at %power|%",
|
"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.setBrake|block": "set `icons.motorLarge` %motor|brake %brake",
|
||||||
"motors.Motor.setReversed|block": "set `icons.motorLarge` %motor|reversed %reversed",
|
"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.speed|block": "`icons.motorLarge` %motor|speed",
|
||||||
"motors.Motor.stop|block": "stop `icons.motorLarge` %motor",
|
"motors.Motor.stop|block": "stop `icons.motorLarge` %motor",
|
||||||
"motors.Motor.tachoCount|block": "`icons.motorLarge` %motor|tacho count",
|
"motors.Motor.tachoCount|block": "`icons.motorLarge` %motor|tacho count",
|
||||||
|
@ -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 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
|
//% weight=99 group="Motors" blockGap=8
|
||||||
//% power.min=-100 power.max=100
|
//% power.min=-100 power.max=100
|
||||||
power(power: number) {
|
setSpeed(speed: number) {
|
||||||
power = Math.clamp(-100, 100, power >> 0);
|
speed = Math.clamp(-100, 100, speed >> 0);
|
||||||
|
|
||||||
// per LEGO: call it power, use speed
|
// per LEGO: call it power, use speed
|
||||||
const b = mkCmd(this.port, DAL.opOutputSpeed, 1)
|
const b = mkCmd(this.port, DAL.opOutputSpeed, 1)
|
||||||
b.setNumber(NumberFormat.Int8LE, 2, power)
|
b.setNumber(NumberFormat.Int8LE, 2, speed)
|
||||||
writePWM(b)
|
writePWM(b)
|
||||||
if (power) {
|
if (speed) {
|
||||||
const b = mkCmd(this.port, DAL.opOutputStart, 0)
|
const b = mkCmd(this.port, DAL.opOutputStart, 0)
|
||||||
writePWM(b);
|
writePWM(b);
|
||||||
} else {
|
} else {
|
||||||
@ -141,7 +141,7 @@ namespace motors {
|
|||||||
const b = mkCmd(this.port, DAL.opOutputStop, 1)
|
const b = mkCmd(this.port, DAL.opOutputStop, 1)
|
||||||
b.setNumber(NumberFormat.UInt8LE, 2, this.brake ? 1 : 0)
|
b.setNumber(NumberFormat.UInt8LE, 2, this.brake ? 1 : 0)
|
||||||
writePWM(b);
|
writePWM(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the automatic brake on or off when the motor is off
|
* Sets the automatic brake on or off when the motor is off
|
||||||
|
Loading…
Reference in New Issue
Block a user