From 580b40876c2efe6bbf56ee7afe240111fb86f664 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 28 Nov 2017 16:02:04 -0800 Subject: [PATCH] fixing bumped --- libs/core/buttons.ts | 8 ++++---- libs/core/core.ts | 2 +- libs/core/input.ts | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index 2e04f419..348fdc13 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -68,15 +68,15 @@ namespace brick { _update(curr: boolean) { if (this._isPressed == curr) return this._isPressed = curr - if (curr) this._wasPressed = true; if (curr) { + this._wasPressed = true; this.downTime = control.millis() control.raiseEvent(this._id, ButtonEvent.Down) } else { control.raiseEvent(this._id, ButtonEvent.Up) - let delta = control.millis() - this.downTime - control.raiseEvent(this._id, ButtonEvent.Click) - //control.raiseEvent(this._id, delta > 500 ? ButtonEvent.LongClick : ButtonEvent.Click) + const delta = control.millis() - this.downTime; + if (delta < 500) + control.raiseEvent(this._id, ButtonEvent.Click) } } diff --git a/libs/core/core.ts b/libs/core/core.ts index 32d804bf..a40184bf 100644 --- a/libs/core/core.ts +++ b/libs/core/core.ts @@ -10,7 +10,7 @@ namespace control { this._id = id } - getId() { + id() { return this._id; } } diff --git a/libs/core/input.ts b/libs/core/input.ts index 6f8c3ff9..894c9203 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -132,26 +132,26 @@ namespace sensors.internal { } export class Sensor extends control.Component { - protected port: number // this is 0-based + protected _port: number // this is 0-based constructor(port_: number) { super() if (!(1 <= port_ && port_ <= DAL.NUM_INPUTS)) control.panic(120) - this.port = port_ - 1 + this._port = port_ - 1 init() - sensorInfos[this.port].sensors.push(this) + sensorInfos[this._port].sensors.push(this) } _activated() { } // 1-based - getPort() { - return this.port + 1 + port() { + return this._port + 1 } isActive() { - return sensorInfos[this.port].sensor == this + return sensorInfos[this._port].sensor == this } _query() { @@ -173,7 +173,7 @@ namespace sensors.internal { _readPin6() { if (!this.isActive()) return 0 - return analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.InPin6 + 2 * this.port) + return analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.InPin6 + 2 * this._port) } } @@ -202,18 +202,18 @@ namespace sensors.internal { if (!this.isActive()) return if (this.realmode != this.mode) { this.realmode = v - setUartMode(this.port, v) + setUartMode(this._port, v) } } getBytes(): Buffer { - return getUartBytes(this.isActive() ? this.port : -1) + return getUartBytes(this.isActive() ? this._port : -1) } getNumber(fmt: NumberFormat, off: number) { if (!this.isActive()) return 0 - return getUartNumber(fmt, off, this.port) + return getUartNumber(fmt, off, this._port) } }