threshold query api

This commit is contained in:
Peli de Halleux
2018-01-30 08:27:23 -08:00
parent 16c67f0e30
commit 188d5b3aa7
10 changed files with 68 additions and 13 deletions

View File

@ -258,7 +258,7 @@ namespace sensors {
* @param value the value threshold
*/
//% blockId=irSetThreshold block="set %sensor|%condition|to %value"
//% group="Threshold" blockGap=8
//% group="Threshold" blockGap=8 weight=49
//% value.min=0 value.max=100
setThreshold(condition: InfraredSensorEvent, value: number) {
if (condition == InfraredSensorEvent.ObjectNear)
@ -266,6 +266,17 @@ namespace sensors {
else
this.proximityThreshold.setHighThreshold(value);
}
/**
* Gets the threshold value
* @param condition the proximity condition
*/
//% blockId=irGetThreshold block="%sensor|%condition"
//% group="Threshold" blockGap=8 weight=49
//% sensor.fieldEditor="ports"
threshold(condition: InfraredSensorEvent): number {
return this.proximityThreshold.threshold(<ThresholdState><number>LightCondition.Dark);
}
}
//% fixedInstance whenUsed block="infrared 1" jres=icons.port1