renaming 'set speed' to 'run' (#327)

This commit is contained in:
Peli de Halleux
2018-02-19 07:35:08 -08:00
committed by GitHub
parent 3b6cfed5b2
commit fad4ca98db
41 changed files with 177 additions and 177 deletions

View File

@ -134,17 +134,17 @@ namespace motors {
protected _brake: boolean;
private _initialized: boolean;
private _init: () => void;
private _setSpeed: (speed: number) => void;
private _run: (speed: number) => void;
private _move: (steps: boolean, stepsOrTime: number, speed: number) => void;
constructor(port: Output, init: () => void, setSpeed: (speed: number) => void, move: (steps: boolean, stepsOrTime: number, speed: number) => void) {
constructor(port: Output, init: () => void, run: (speed: number) => void, move: (steps: boolean, stepsOrTime: number, speed: number) => void) {
super();
this._port = port;
this._portName = outputToName(this._port);
this._brake = false;
this._initialized = false;
this._init = init;
this._setSpeed = setSpeed;
this._run = run;
this._move = move;
}
@ -218,17 +218,17 @@ namespace motors {
}
/**
* Sets the motor speed for limited time or distance.
* Runs the motor at a given speed for limited time or distance.
* @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
* @param value (optional) measured distance or rotation
* @param unit (optional) unit of the value
*/
//% blockId=motorSetSpeed block="set %motor speed to %speed=motorSpeedPicker|\\%||for %value %unit"
//% blockId=motorRun block="run %motor at %speed=motorSpeedPicker|\\%||for %value %unit"
//% weight=100 blockGap=8
//% group="Move"
//% expandableArgumentMode=toggle
//% help=motors/motor/set-speed
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
//% help=motors/motor/run
run(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
this.init();
speed = Math.clamp(-100, 100, speed >> 0);
// stop if speed is 0
@ -238,7 +238,7 @@ namespace motors {
}
// special: 0 is infinity
if (value == 0) {
this._setSpeed(speed);
this._run(speed);
return;
}
// timed motor moves