Safepolling (#915)

* headstart on safe polling

* poke in sensors

* more poking

* typo
This commit is contained in:
Peli de Halleux
2019-09-17 14:30:02 -07:00
committed by GitHub
parent 64a9930c2e
commit 6f34887c94
8 changed files with 105 additions and 53 deletions

View File

@ -235,6 +235,7 @@ namespace sensors {
//% group="Infrared Sensor"
//% this.fieldEditor="ports"
proximity(): number {
this.poke();
this._setMode(InfraredSensorMode.Proximity)
return this.getNumber(NumberFormat.UInt8LE, 0)
}
@ -284,6 +285,7 @@ namespace sensors {
// TODO
private getDirectionAndDistance() {
this.poke();
this._setMode(InfraredSensorMode.Seek)
return this.getNumber(NumberFormat.UInt16LE, this._channel * 2)
}