Don't reset threashold when resetting color mode (#932)

* don't reset threshold when changing modes

* updated docs
This commit is contained in:
Peli de Halleux 2019-10-01 13:27:37 -07:00 committed by GitHub
parent d179f18ef3
commit f745079728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -32,6 +32,10 @@
"name": "Moving with Gyro", "name": "Moving with Gyro",
"description": "Use the gyro for correct the robot trajectory.", "description": "Use the gyro for correct the robot trajectory.",
"youTubeId": "ufiOPvW37xc" "youTubeId": "ufiOPvW37xc"
}, {
"name": "Line following with 1 color sensor",
"description": "Simple line following using the color sensor.",
"youTubeId": "_LeduyKQVjg"
}] }]
``` ```

View File

@ -73,13 +73,7 @@ namespace sensors {
} }
setMode(m: ColorSensorMode) { setMode(m: ColorSensorMode) {
if (m == ColorSensorMode.AmbientLightIntensity) { // don't change threshold after initialization
this.thresholdDetector.setLowThreshold(5);
this.thresholdDetector.setHighThreshold(20);
} else {
this.thresholdDetector.setLowThreshold(20);
this.thresholdDetector.setHighThreshold(80);
}
this._setMode(m) this._setMode(m)
} }

View File

@ -814,10 +814,10 @@ namespace sensors {
export class ThresholdDetector { export class ThresholdDetector {
public id: number; public id: number;
public min: number; private min: number;
public max: number; private max: number;
public lowThreshold: number; private lowThreshold: number;
public highThreshold: number; private highThreshold: number;
public level: number; public level: number;
public state: ThresholdState; public state: ThresholdState;