diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 5be2fc4f..15ad475e 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -71,29 +71,21 @@ "motors.MotorBase.setBrake": "Sets the automatic brake on or off when the motor is off", "motors.MotorBase.setBrake|param|brake": "a value indicating if the motor should break when off", "motors.MotorBase.setReversed": "Reverses the motor polarity", - "motors.MotorBase.setSpeed": "Sets the speed of the motor.", - "motors.MotorBase.setSpeedFor": "Sets the motor speed for limited time or distance", - "motors.MotorBase.setSpeedFor|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50", - "motors.MotorBase.setSpeedFor|param|unit": "the meaning of the value", - "motors.MotorBase.setSpeedFor|param|value": "the move quantity, eg: 2", + "motors.MotorBase.setSpeed": "Sets the motor speed for limited time or distance", "motors.MotorBase.setSpeed|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50", + "motors.MotorBase.setSpeed|param|unit": "(optional) unit of the value", + "motors.MotorBase.setSpeed|param|value": "(optional) measured distance or rotation", "motors.MotorBase.stop": "Stops the motor(s).", "motors.SynchedMotorPair.steer": "Turns the motor and the follower motor by a number of rotations", - "motors.SynchedMotorPair.steerFor": "Turns the motor and the follower motor by a number of rotations", - "motors.SynchedMotorPair.steerFor|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50", - "motors.SynchedMotorPair.steerFor|param|turnRatio": "the ratio of power sent to the follower motor, from ``-200`` to ``200``, eg: 0", - "motors.SynchedMotorPair.steerFor|param|unit": "the meaning of the value", - "motors.SynchedMotorPair.steerFor|param|value": "the move quantity, eg: 2", "motors.SynchedMotorPair.steer|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50", "motors.SynchedMotorPair.steer|param|turnRatio": "the ratio of power sent to the follower motor, from ``-200`` to ``200``, eg: 0", + "motors.SynchedMotorPair.steer|param|unit": "(optional) unit of the value", + "motors.SynchedMotorPair.steer|param|value": "(optional) move duration or rotation", "motors.SynchedMotorPair.tank": "The Move Tank block can make a robot drive forward, backward, turn, or stop. \nUse the Move Tank block for robot vehicles that have two Large Motors, \nwith one motor driving the left side of the vehicle and the other the right side. \nYou can make the two motors go at different speeds or in different directions \nto make your robot turn.", - "motors.SynchedMotorPair.tankFor": "The Move Tank block can make a robot drive forward, backward, turn, or stop. \nUse the Move Tank block for robot vehicles that have two Large Motors, \nwith one motor driving the left side of the vehicle and the other the right side. \nYou can make the two motors go at different speeds or in different directions \nto make your robot turn.", - "motors.SynchedMotorPair.tankFor|param|speedLeft": "the speed on the left motor, eg: 50", - "motors.SynchedMotorPair.tankFor|param|speedRight": "the speed on the right motor, eg: 50", - "motors.SynchedMotorPair.tankFor|param|unit": "the unit of the value", - "motors.SynchedMotorPair.tankFor|param|value": "the amount of movement, eg: 2", "motors.SynchedMotorPair.tank|param|speedLeft": "the speed on the left motor, eg: 50", "motors.SynchedMotorPair.tank|param|speedRight": "the speed on the right motor, eg: 50", + "motors.SynchedMotorPair.tank|param|unit": "(optional) unit of the value", + "motors.SynchedMotorPair.tank|param|value": "(optional) move duration or rotation", "motors.SynchedMotorPair.toString": "Returns the name(s) of the motor", "motors.mkCmd": "Allocates a message buffer", "motors.mkCmd|param|addSize": "required additional bytes", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index aecf7fe8..aa4d65d0 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -57,11 +57,8 @@ "motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready", "motors.MotorBase.setBrake|block": "set %motor|brake %brake", "motors.MotorBase.setReversed|block": "set %motor|reversed %reversed", - "motors.MotorBase.setSpeedFor|block": "set %motor|speed to %speed=motorSpeedPicker|%|for %value|%unit", "motors.MotorBase.setSpeed|block": "set %motor|speed to %speed=motorSpeedPicker|%", - "motors.SynchedMotorPair.steerFor|block": "steer %chassis|turn ratio %turnRatio|speed %speed=motorSpeedPicker|%|for %value|%unit", "motors.SynchedMotorPair.steer|block": "steer %chassis|turn ratio %turnRatio|speed %speed=motorSpeedPicker|%", - "motors.SynchedMotorPair.tankFor|block": "tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%|for %value|%unit", "motors.SynchedMotorPair.tank|block": "tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%", "motors.largeAB|block": "large A+B", "motors.largeAD|block": "large A+D", @@ -94,7 +91,6 @@ "{id:group}Buttons": "Buttons", "{id:group}Counters": "Counters", "{id:group}Light": "Light", - "{id:group}Measured Move": "Measured Move", "{id:group}More": "More", "{id:group}Move": "Move", "{id:group}Screen": "Screen", diff --git a/libs/core/output.ts b/libs/core/output.ts index de4ae742..cacfc32a 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -96,7 +96,7 @@ namespace motors { return b } - function outputToName(out: Output): string { + export function outputToName(out: Output): string { let r = ""; for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) { if (out & (1 << i)) { @@ -202,33 +202,16 @@ namespace motors { reset(this._port); } - /** - * Sets the speed of the motor. - * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50 - */ - //% blockId=motorSetSpeed block="set %motor|speed to %speed=motorSpeedPicker|%" - //% on.fieldEditor=toggleonoff - //% weight=99 blockGap=8 - //% group="Move" - setSpeed(speed: number) { - this.init(); - speed = Math.clamp(-100, 100, speed >> 0); - if (!speed) // always stop - this.stop(); - else - this._setSpeed(speed); - } - /** * Sets the motor speed for limited time or distance * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50 - * @param value the move quantity, eg: 2 - * @param unit the meaning of the value + * @param value (optional) measured distance or rotation + * @param unit (optional) unit of the value */ - //% blockId=motorMove block="set %motor|speed to %speed=motorSpeedPicker|%|for %value|%unit" - //% weight=98 blockGap=8 - //% group="Measured Move" - setSpeedFor(speed: number, value: number, unit: MoveUnit) { + //% blockId=motorSetSpeed block="set %motor|speed to %speed=motorSpeedPicker|%" + //% weight=100 blockGap=8 + //% group="Move" + setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) { this.init(); speed = Math.clamp(-100, 100, speed >> 0); if (!speed) { @@ -455,7 +438,6 @@ namespace motors { }); } - /** * The Move Tank block can make a robot drive forward, backward, turn, or stop. * Use the Move Tank block for robot vehicles that have two Large Motors, @@ -464,30 +446,14 @@ namespace motors { * to make your robot turn. * @param speedLeft the speed on the left motor, eg: 50 * @param speedRight the speed on the right motor, eg: 50 + * @param value (optional) move duration or rotation + * @param unit (optional) unit of the value */ //% blockId=motorPairTank block="tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%" //% weight=96 blockGap=8 - //% group="Move" - tank(speedLeft: number, speedRight: number) { - this.tankFor(speedLeft, speedRight, 0, MoveUnit.Degrees); - } - - /** - * The Move Tank block can make a robot drive forward, backward, turn, or stop. - * Use the Move Tank block for robot vehicles that have two Large Motors, - * with one motor driving the left side of the vehicle and the other the right side. - * You can make the two motors go at different speeds or in different directions - * to make your robot turn. - * @param speedLeft the speed on the left motor, eg: 50 - * @param speedRight the speed on the right motor, eg: 50 - * @param value the amount of movement, eg: 2 - * @param unit the unit of the value - */ - //% blockId=motorPairTankFor block="tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%|for %value|%unit" - //% weight=19 blockGap=8 //% inlineInputMode=inline - //% group="Measured Move" - tankFor(speedLeft: number, speedRight: number, value: number, unit: MoveUnit) { + //% group="Move" + tank(speedLeft: number, speedRight: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) { this.init(); speedLeft = Math.clamp(-100, 100, speedLeft >> 0); @@ -498,39 +464,22 @@ namespace motors { ? (100 - speedRight / speedLeft * 100) : (speedLeft / speedRight * 100 - 100); - this.steerFor(turnRatio, speed, value, unit); + this.steer(turnRatio, speed, value, unit); } - /** * Turns the motor and the follower motor by a number of rotations * @param turnRatio the ratio of power sent to the follower motor, from ``-200`` to ``200``, eg: 0 * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50 - * @param value the move quantity, eg: 2 - * @param unit the meaning of the value + * @param value (optional) move duration or rotation + * @param unit (optional) unit of the value */ //% blockId=motorPairSteer block="steer %chassis|turn ratio %turnRatio|speed %speed=motorSpeedPicker|%" //% weight=95 //% turnRatio.min=-200 turnRatio=200 //% inlineInputMode=inline //% group="Move" - steer(turnRatio: number, speed: number) { - this.steerFor(turnRatio, speed, 0, MoveUnit.Rotations); - } - - /** - * Turns the motor and the follower motor by a number of rotations - * @param turnRatio the ratio of power sent to the follower motor, from ``-200`` to ``200``, eg: 0 - * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50 - * @param value the move quantity, eg: 2 - * @param unit the meaning of the value - */ - //% blockId=motorPairSteerFor block="steer %chassis|turn ratio %turnRatio|speed %speed=motorSpeedPicker|%|for %value|%unit" - //% weight=6 - //% turnRatio.min=-200 turnRatio=200 - //% inlineInputMode=inline - //% group="Measured Move" - steerFor(turnRatio: number, speed: number, value: number, unit: MoveUnit) { + steer(turnRatio: number, speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) { this.init(); speed = Math.clamp(-100, 100, speed >> 0); if (!speed) { diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index e9ce2463..2b16c053 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -14,7 +14,7 @@ namespace sensors { } //% color="#A5CA18" weight=90 icon="\uf10d" -//% groups='["Move", "Counters", "Measured Move"]' +//% groups='["Move", "Counters"]' //% labelLineWidth=0 namespace motors { }