fixing motors

This commit is contained in:
Peli de Halleux 2018-01-10 11:14:18 -08:00
parent f64bf57000
commit 951b9be6e4

View File

@ -216,10 +216,16 @@ namespace motors {
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
this.init();
speed = Math.clamp(-100, 100, speed >> 0);
// stop if speed is 0
if (!speed) {
this.stop();
return;
}
// special: 0 is infinity
if (value == 0) {
this._setSpeed(speed);
return;
}
let useSteps: boolean;
let stepsOrTime: number;
switch (unit) {