From 56ebc21db8af43474c5a25db4e2cdf31103d6aca Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Sat, 4 Aug 2018 23:29:36 +0100 Subject: [PATCH] Added speed ramping capability --- boostmovehub.ts | 6 ++++-- puphub.ts | 6 ++++-- wedo2smarthub.ts | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/boostmovehub.ts b/boostmovehub.ts index 2f4dbfd..2eb37eb 100644 --- a/boostmovehub.ts +++ b/boostmovehub.ts @@ -144,9 +144,11 @@ export class BoostMoveHub extends LPF2Hub { */ public rampMotorSpeed (port: string, fromSpeed: number, toSpeed: number, time: number) { return new Promise((resolve, reject) => { - this._calculateRamp(fromSpeed, toSpeed, time).on("changeSpeed", (speed) => { + this._calculateRamp(fromSpeed, toSpeed, time) + .on("changeSpeed", (speed) => { this.setMotorSpeed(port, speed); - }).on("finished", resolve); + }) + .on("finished", resolve); }); } diff --git a/puphub.ts b/puphub.ts index 47e3cb3..813402c 100644 --- a/puphub.ts +++ b/puphub.ts @@ -138,9 +138,11 @@ export class PUPHub extends LPF2Hub { */ public rampMotorSpeed (port: string, fromSpeed: number, toSpeed: number, time: number) { return new Promise((resolve, reject) => { - this._calculateRamp(fromSpeed, toSpeed, time).on("changeSpeed", (speed) => { + this._calculateRamp(fromSpeed, toSpeed, time) + .on("changeSpeed", (speed) => { this.setMotorSpeed(port, speed); - }).on("finished", resolve); + }) + .on("finished", resolve); }); } diff --git a/wedo2smarthub.ts b/wedo2smarthub.ts index 4a9ff9c..b77935e 100644 --- a/wedo2smarthub.ts +++ b/wedo2smarthub.ts @@ -147,9 +147,11 @@ export class WeDo2SmartHub extends Hub { */ public rampMotorSpeed (port: string, fromSpeed: number, toSpeed: number, time: number) { return new Promise((resolve, reject) => { - this._calculateRamp(fromSpeed, toSpeed, time).on("changeSpeed", (speed) => { + this._calculateRamp(fromSpeed, toSpeed, time) + .on("changeSpeed", (speed) => { this.setMotorSpeed(port, speed); - }).on("finished", resolve); + }) + .on("finished", resolve); }); }