From 12ddb5c72e0398be8ff73f9e50548df48b1fd3b5 Mon Sep 17 00:00:00 2001 From: Joey Wunderlich Date: Fri, 7 Jun 2019 17:20:08 -0700 Subject: [PATCH] always shake when button is pressed (#2161) --- sim/state/accelerometer.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sim/state/accelerometer.ts b/sim/state/accelerometer.ts index 8baba149..80172fd6 100644 --- a/sim/state/accelerometer.ts +++ b/sim/state/accelerometer.ts @@ -267,7 +267,7 @@ namespace pxsim { ++this.sigma; } - if (this.sigma >= DAL.MICROBIT_ACCELEROMETER_GESTURE_DAMPING) { + if (this.currentGesture !== this.lastGesture && this.sigma >= DAL.MICROBIT_ACCELEROMETER_GESTURE_DAMPING) { this.enqueueCurrentGesture(); } } @@ -278,10 +278,8 @@ namespace pxsim { } private enqueueCurrentGesture() { - if (this.currentGesture != this.lastGesture) { - this.lastGesture = this.currentGesture; - board().bus.queue(DAL.MICROBIT_ID_GESTURE, this.lastGesture); - } + this.lastGesture = this.currentGesture; + board().bus.queue(DAL.MICROBIT_ID_GESTURE, this.lastGesture); } /**