adding a few pause to allow motors to settle

This commit is contained in:
Peli de Halleux 2019-09-17 11:23:40 -07:00
parent 3769402ade
commit 361ae7a2d2

View File

@ -123,7 +123,8 @@ namespace motors {
//% help=motors/stop-all //% help=motors/stop-all
export function stopAll() { export function stopAll() {
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0) const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
writePWM(b) writePWM(b);
pause(1);
} }
/** /**
@ -132,6 +133,7 @@ namespace motors {
//% group="Move" //% group="Move"
export function resetAllMotors() { export function resetAllMotors() {
reset(Output.ALL) reset(Output.ALL)
pause(1);
} }
interface MoveSchedule { interface MoveSchedule {
@ -259,6 +261,8 @@ namespace motors {
// allow 500ms for robot to settle // allow 500ms for robot to settle
if (this._brake && this._brakeSettleTime > 0) if (this._brake && this._brakeSettleTime > 0)
pause(this._brakeSettleTime); pause(this._brakeSettleTime);
else
pause(1); // give a tiny breather
} }
protected pauseOnRun(stepsOrTime: number) { protected pauseOnRun(stepsOrTime: number) {
@ -337,6 +341,7 @@ namespace motors {
// special: 0 is infinity // special: 0 is infinity
if (schedule.steps[0] + schedule.steps[1] + schedule.steps[2] == 0) { if (schedule.steps[0] + schedule.steps[1] + schedule.steps[2] == 0) {
this._run(schedule.speed); this._run(schedule.speed);
pause(1);
return; return;
} }
@ -700,7 +705,7 @@ namespace motors {
this.init(); this.init();
speed = Math.clamp(-100, 100, speed >> 0); speed = Math.clamp(-100, 100, speed >> 0);
if (!speed) { if (!speed) {
stop(this._port, this._brake); this.stop();
return; return;
} }