Threshold to calibration (#495)

* renaming threshold to calibration

* rename threshold to calibration
This commit is contained in:
Peli de Halleux 2018-04-12 14:25:44 -07:00 committed by Sam El-Husseini
parent 2c874570ce
commit bd06fb80f3
4 changed files with 15 additions and 9 deletions

View File

@ -232,11 +232,17 @@ namespace sensors {
return this.getNumber(NumberFormat.UInt8LE, 0) return this.getNumber(NumberFormat.UInt8LE, 0)
} }
/**
* Gets the ambient light
*/
//% //%
ambientLight() { ambientLight() {
return this.light(LightIntensityMode.Ambient); return this.light(LightIntensityMode.Ambient);
} }
/**
* Gets the reflected light value
*/
//% //%
reflectedLight() { reflectedLight() {
return this.light(LightIntensityMode.Reflected); return this.light(LightIntensityMode.Reflected);
@ -245,10 +251,10 @@ namespace sensors {
/** /**
* Set a threshold value * Set a threshold value
* @param condition the dark or bright light condition * @param condition the dark or bright light condition
* @param value the value threshold * @param value the value threshold, eg: 10
*/ */
//% blockId=colorSetThreshold block="set **color sensor** %this|%condition|to %value" //% blockId=colorSetThreshold block="set **color sensor** %this|%condition|to %value"
//% group="Threshold" blockGap=8 weight=90 //% group="Calibration" blockGap=8 weight=90
//% value.min=0 value.max=100 //% value.min=0 value.max=100
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
//% help=sensors/color-sensor/set-threshold //% help=sensors/color-sensor/set-threshold
@ -269,7 +275,7 @@ namespace sensors {
* @param condition the light condition * @param condition the light condition
*/ */
//% blockId=colorGetThreshold block="**color sensor** %this|%condition" //% blockId=colorGetThreshold block="**color sensor** %this|%condition"
//% group="Threshold" blockGap=8 weight=89 //% group="Calibration" weight=89
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
//% help=sensors/color-sensor/threshold //% help=sensors/color-sensor/threshold
threshold(condition: Light): number { threshold(condition: Light): number {
@ -285,7 +291,7 @@ namespace sensors {
* Collects measurement of the light condition and adjusts the threshold to 10% / 90%. * Collects measurement of the light condition and adjusts the threshold to 10% / 90%.
*/ */
//% blockId=colorCalibrateLight block="calibrate **color sensor** %this|for %mode" //% blockId=colorCalibrateLight block="calibrate **color sensor** %this|for %mode"
//% group="Threshold" weight=91 blockGap=8 //% group="Calibration" weight=91 blockGap=8
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
//% help=sensors/color-sensor/calibrate-light //% help=sensors/color-sensor/calibrate-light
calibrateLight(mode: LightIntensityMode, deviation: number = 8) { calibrateLight(mode: LightIntensityMode, deviation: number = 8) {

View File

@ -8,7 +8,7 @@ namespace brick {
//% color="#C8509B" weight=95 icon="\uf10f" //% color="#C8509B" weight=95 icon="\uf10f"
//% labelLineWidth=100 //% labelLineWidth=100
//% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Gyro Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Threshold"]' //% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Gyro Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Calibration"]'
namespace sensors { namespace sensors {
} }

View File

@ -261,7 +261,7 @@ namespace sensors {
* @param value the value threshold * @param value the value threshold
*/ */
//% blockId=irSetThreshold block="set **infrared** %this|%condition|to %value" //% blockId=irSetThreshold block="set **infrared** %this|%condition|to %value"
//% group="Threshold" blockGap=8 weight=49 //% group="Calibration" blockGap=8 weight=49
//% value.min=0 value.max=100 //% value.min=0 value.max=100
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
setPromixityThreshold(condition: InfraredSensorEvent, value: number) { setPromixityThreshold(condition: InfraredSensorEvent, value: number) {
@ -276,7 +276,7 @@ namespace sensors {
* @param condition the proximity condition * @param condition the proximity condition
*/ */
//% blockId=irGetThreshold block="**infrared** %this|%condition" //% blockId=irGetThreshold block="**infrared** %this|%condition"
//% group="Threshold" blockGap=8 weight=49 //% group="Calibration" weight=49
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
proximityThreshold(condition: InfraredSensorEvent): number { proximityThreshold(condition: InfraredSensorEvent): number {
return this._proximityThreshold.threshold(<ThresholdState><number>condition); return this._proximityThreshold.threshold(<ThresholdState><number>condition);

View File

@ -96,7 +96,7 @@ namespace sensors {
* @param value the value threshold * @param value the value threshold
*/ */
//% blockId=ultrasonicSetThreshold block="set **ultrasonic** %this|%condition|to %value" //% blockId=ultrasonicSetThreshold block="set **ultrasonic** %this|%condition|to %value"
//% group="Threshold" blockGap=8 weight=80 //% group="Calibration" blockGap=8 weight=80
//% value.min=0 value.max=255 //% value.min=0 value.max=255
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
setThreshold(condition: UltrasonicSensorEvent, value: number) { setThreshold(condition: UltrasonicSensorEvent, value: number) {
@ -111,7 +111,7 @@ namespace sensors {
* @param condition the proximity condition * @param condition the proximity condition
*/ */
//% blockId=ultrasonicGetThreshold block="**ultrasonic** %this|%condition" //% blockId=ultrasonicGetThreshold block="**ultrasonic** %this|%condition"
//% group="Threshold" blockGap=8 weight=79 //% group="Calibration" weight=79
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
threshold(condition: UltrasonicSensorEvent): number { threshold(condition: UltrasonicSensorEvent): number {
switch (condition) { switch (condition) {