2017-07-10 12:37:14 +02:00
|
|
|
namespace input {
|
|
|
|
export class TouchSensor extends internal.AnalogSensor {
|
2017-07-10 12:43:50 +02:00
|
|
|
button: Button;
|
2017-07-10 12:37:14 +02:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super()
|
2017-07-10 12:43:50 +02:00
|
|
|
this.button = new Button()
|
2017-07-10 12:37:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
_query() {
|
|
|
|
return this._readPin6() > 2500 ? 1 : 0
|
|
|
|
}
|
|
|
|
|
|
|
|
_update(prev: number, curr: number) {
|
|
|
|
this.button.update(curr > 0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//% whenUsed
|
|
|
|
export const touch: TouchSensor = new TouchSensor()
|
|
|
|
}
|