Merge pull request #85 from Microsoft/on_color_fix

Fix "on color detected" block
This commit is contained in:
Peli de Halleux 2017-12-13 15:55:47 -08:00 committed by GitHub
commit e7c697c24d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,9 +106,9 @@ namespace sensors {
//% weight=100 blockGap=8 //% weight=100 blockGap=8
//% group="Color Sensor" //% group="Color Sensor"
onColorDetected(color: ColorSensorColor, handler: () => void) { onColorDetected(color: ColorSensorColor, handler: () => void) {
this.setMode(ColorSensorMode.Color)
const v = this._colorEventValue(<number>color); const v = this._colorEventValue(<number>color);
control.onEvent(this._id, v, handler); control.onEvent(this._id, v, handler);
this.setMode(ColorSensorMode.Color)
if (this.color() == color) if (this.color() == color)
control.raiseEvent(this._id, v); control.raiseEvent(this._id, v);
} }