fixing motors
This commit is contained in:
parent
f64bf57000
commit
951b9be6e4
@ -216,10 +216,16 @@ namespace motors {
|
|||||||
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||||
this.init();
|
this.init();
|
||||||
speed = Math.clamp(-100, 100, speed >> 0);
|
speed = Math.clamp(-100, 100, speed >> 0);
|
||||||
|
// stop if speed is 0
|
||||||
if (!speed) {
|
if (!speed) {
|
||||||
this.stop();
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// special: 0 is infinity
|
||||||
|
if (value == 0) {
|
||||||
|
this._setSpeed(speed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
let useSteps: boolean;
|
let useSteps: boolean;
|
||||||
let stepsOrTime: number;
|
let stepsOrTime: number;
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
|
Loading…
Reference in New Issue
Block a user