fixing bumped
This commit is contained in:
		@@ -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;
 | 
				
			||||||
 | 
					                if (delta < 500)
 | 
				
			||||||
                    control.raiseEvent(this._id, ButtonEvent.Click)
 | 
					                    control.raiseEvent(this._id, ButtonEvent.Click)
 | 
				
			||||||
                //control.raiseEvent(this._id, delta > 500 ? ButtonEvent.LongClick : ButtonEvent.Click)
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ namespace control {
 | 
				
			|||||||
            this._id = id
 | 
					            this._id = id
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        getId() {
 | 
					        id() {
 | 
				
			||||||
            return this._id;
 | 
					            return this._id;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user