fixing bumped

This commit is contained in:
Peli de Halleux 2017-11-28 16:02:04 -08:00
parent b57ae5d588
commit 580b40876c
3 changed files with 15 additions and 15 deletions

View File

@ -68,15 +68,15 @@ namespace brick {
_update(curr: boolean) { _update(curr: boolean) {
if (this._isPressed == curr) return if (this._isPressed == curr) return
this._isPressed = curr this._isPressed = curr
if (curr) this._wasPressed = true;
if (curr) { if (curr) {
this._wasPressed = true;
this.downTime = control.millis() this.downTime = control.millis()
control.raiseEvent(this._id, ButtonEvent.Down) control.raiseEvent(this._id, ButtonEvent.Down)
} else { } else {
control.raiseEvent(this._id, ButtonEvent.Up) control.raiseEvent(this._id, ButtonEvent.Up)
let delta = control.millis() - this.downTime const delta = control.millis() - this.downTime;
control.raiseEvent(this._id, ButtonEvent.Click) if (delta < 500)
//control.raiseEvent(this._id, delta > 500 ? ButtonEvent.LongClick : ButtonEvent.Click) control.raiseEvent(this._id, ButtonEvent.Click)
} }
} }

View File

@ -10,7 +10,7 @@ namespace control {
this._id = id this._id = id
} }
getId() { id() {
return this._id; return this._id;
} }
} }

View File

@ -132,26 +132,26 @@ namespace sensors.internal {
} }
export class Sensor extends control.Component { export class Sensor extends control.Component {
protected port: number // this is 0-based protected _port: number // this is 0-based
constructor(port_: number) { constructor(port_: number) {
super() super()
if (!(1 <= port_ && port_ <= DAL.NUM_INPUTS)) if (!(1 <= port_ && port_ <= DAL.NUM_INPUTS))
control.panic(120) control.panic(120)
this.port = port_ - 1 this._port = port_ - 1
init() init()
sensorInfos[this.port].sensors.push(this) sensorInfos[this._port].sensors.push(this)
} }
_activated() { } _activated() { }
// 1-based // 1-based
getPort() { port() {
return this.port + 1 return this._port + 1
} }
isActive() { isActive() {
return sensorInfos[this.port].sensor == this return sensorInfos[this._port].sensor == this
} }
_query() { _query() {
@ -173,7 +173,7 @@ namespace sensors.internal {
_readPin6() { _readPin6() {
if (!this.isActive()) return 0 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.isActive()) return
if (this.realmode != this.mode) { if (this.realmode != this.mode) {
this.realmode = v this.realmode = v
setUartMode(this.port, v) setUartMode(this._port, v)
} }
} }
getBytes(): Buffer { getBytes(): Buffer {
return getUartBytes(this.isActive() ? this.port : -1) return getUartBytes(this.isActive() ? this._port : -1)
} }
getNumber(fmt: NumberFormat, off: number) { getNumber(fmt: NumberFormat, off: number) {
if (!this.isActive()) if (!this.isActive())
return 0 return 0
return getUartNumber(fmt, off, this.port) return getUartNumber(fmt, off, this._port)
} }
} }