pxt-ev3/libs/core/touch.ts
2017-07-10 12:48:04 +01:00

26 lines
538 B
TypeScript

namespace input {
export class TouchSensor extends internal.AnalogSensor {
button: ButtonTS;
constructor() {
super()
this.button = new ButtonTS()
}
_query() {
return this._readPin6() > 2500 ? 1 : 0
}
_update(prev: number, curr: number) {
this.button.update(curr > 0)
}
_deviceType() {
return LMS.DEVICE_TYPE_TOUCH
}
}
//% whenUsed
export const touch: TouchSensor = new TouchSensor()
}