Thresholds (#222)

* add threshold blocks

* updated strings

* added gap

* reorg color/gyro blocks

* fixing sound names

* adding stop block

* fixing exanmples
This commit is contained in:
Peli de Halleux
2018-01-09 12:46:48 -08:00
committed by GitHub
parent 9890f2340a
commit 892a2d585f
20 changed files with 131 additions and 69 deletions

View File

@ -250,6 +250,21 @@ namespace sensors {
this._setMode(IrSensorMode.Seek)
return this.getNumber(NumberFormat.UInt16LE, this.channel * 2)
}
/**
* Sets a threshold value
* @param condition the dark or bright light condition
* @param value the value threshold
*/
//% blockId=irSetThreshold block="set %condition|to %value"
//% group="Threshold" blockGap=8
setThreshold(condition: InfraredSensorEvent, value: number) {
if (condition == InfraredSensorEvent.ObjectNear)
this.proximityThreshold.setLowThreshold(value)
else
this.proximityThreshold.setHighThreshold(value);
}
}
//% fixedInstance whenUsed block="infrared 1" jres=icons.port1