From 751ea1494b5c2ea81fbeb598db04918c5dc2b60c Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Fri, 12 Jan 2018 13:33:25 -0800 Subject: [PATCH] motor slider fixes and fix motor output in vm --- libs/core/output.ts | 2 +- sim/state/motornode.ts | 2 +- sim/state/output.ts | 1 + sim/visuals/controls/motorSlider.ts | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/core/output.ts b/libs/core/output.ts index 04cb9878..89d61903 100644 --- a/libs/core/output.ts +++ b/libs/core/output.ts @@ -303,7 +303,7 @@ namespace motors { } private __setSpeed(speed: number) { - const b = mkCmd(this._port, this._regulated ? DAL.opOutputPower : DAL.opOutputSpeed, 1) + const b = mkCmd(this._port, this._regulated ? DAL.opOutputSpeed : DAL.opOutputPower, 1) b.setNumber(NumberFormat.Int8LE, 2, speed) writePWM(b) if (speed) { diff --git a/sim/state/motornode.ts b/sim/state/motornode.ts index 1abab33b..745f046f 100644 --- a/sim/state/motornode.ts +++ b/sim/state/motornode.ts @@ -17,7 +17,7 @@ namespace pxsim { private speedCmdTime: number; private _synchedMotor: MotorNode; // non-null if synchronized - private manualSpeed: number = 0; + private manualSpeed: number = undefined; constructor(port: number, large: boolean) { super(port); diff --git a/sim/state/output.ts b/sim/state/output.ts index 86b2e568..00551ef5 100644 --- a/sim/state/output.ts +++ b/sim/state/output.ts @@ -97,6 +97,7 @@ namespace pxsim { motors.forEach(motor => motor.stop()); return 2; } + case DAL.opOutputPower: case DAL.opOutputSpeed: { // setSpeed const port = buf.data[1]; diff --git a/sim/visuals/controls/motorSlider.ts b/sim/visuals/controls/motorSlider.ts index 2e30731e..ab0b5267 100644 --- a/sim/visuals/controls/motorSlider.ts +++ b/sim/visuals/controls/motorSlider.ts @@ -55,13 +55,13 @@ namespace pxsim.visuals { if (captured && (ev as MouseEvent).clientY != undefined) { ev.preventDefault(); this.updateSliderValue(pt, parent, ev as MouseEvent); - this.handleSliderDown(); + this.handleSliderMove(); } }, ev => { captured = true; if ((ev as MouseEvent).clientY != undefined) { this.updateSliderValue(pt, parent, ev as MouseEvent); - this.handleSliderMove(); + this.handleSliderDown(); } }, () => { captured = false;