Split analog.ts

This commit is contained in:
Michal Moskal
2017-07-10 11:37:14 +01:00
parent c23bf44e35
commit 1e3bce6d44
5 changed files with 219 additions and 213 deletions

21
libs/core/touch.ts Normal file
View File

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