Don't reset threashold when resetting color mode (#932)
* don't reset threshold when changing modes * updated docs
This commit is contained in:
		@@ -32,6 +32,10 @@
 | 
			
		||||
    "name": "Moving with Gyro",
 | 
			
		||||
    "description": "Use the gyro for correct the robot trajectory.",
 | 
			
		||||
    "youTubeId": "ufiOPvW37xc"
 | 
			
		||||
}, {
 | 
			
		||||
    "name": "Line following with 1 color sensor",
 | 
			
		||||
    "description": "Simple line following using the color sensor.",
 | 
			
		||||
    "youTubeId": "_LeduyKQVjg"
 | 
			
		||||
}]
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -73,13 +73,7 @@ namespace sensors {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setMode(m: ColorSensorMode) {
 | 
			
		||||
            if (m == ColorSensorMode.AmbientLightIntensity) {
 | 
			
		||||
                this.thresholdDetector.setLowThreshold(5);
 | 
			
		||||
                this.thresholdDetector.setHighThreshold(20);
 | 
			
		||||
            } else {
 | 
			
		||||
                this.thresholdDetector.setLowThreshold(20);
 | 
			
		||||
                this.thresholdDetector.setHighThreshold(80);
 | 
			
		||||
            }
 | 
			
		||||
            // don't change threshold after initialization
 | 
			
		||||
            this._setMode(m)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -814,10 +814,10 @@ namespace sensors {
 | 
			
		||||
 | 
			
		||||
    export class ThresholdDetector {
 | 
			
		||||
        public id: number;
 | 
			
		||||
        public min: number;
 | 
			
		||||
        public max: number;
 | 
			
		||||
        public lowThreshold: number;
 | 
			
		||||
        public highThreshold: number;
 | 
			
		||||
        private min: number;
 | 
			
		||||
        private max: number;
 | 
			
		||||
        private lowThreshold: number;
 | 
			
		||||
        private highThreshold: number;
 | 
			
		||||
        public level: number;
 | 
			
		||||
        public state: ThresholdState;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user