Rgb raw tuning of blocs (#883)

* refactor blocks

* make non-private
This commit is contained in:
Peli de Halleux 2019-08-27 17:05:16 -07:00 committed by GitHub
parent 79b5f8cc88
commit 3e56e2c3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -15,7 +15,9 @@ enum LightIntensityMode {
//% block="reflected light" //% block="reflected light"
Reflected = ColorSensorMode.ReflectedLightIntensity, Reflected = ColorSensorMode.ReflectedLightIntensity,
//% block="ambient light" //% block="ambient light"
Ambient = ColorSensorMode.AmbientLightIntensity Ambient = ColorSensorMode.AmbientLightIntensity,
//% block="reflected light (raw)"
ReflectedRaw = ColorSensorMode.RefRaw
} }
const enum ColorSensorColor { const enum ColorSensorColor {
@ -186,15 +188,13 @@ namespace sensors {
* @param sensor the color sensor to query the request * @param sensor the color sensor to query the request
*/ */
//% help=sensors/color-sensor/rgbraw //% help=sensors/color-sensor/rgbraw
//% block="**color sensor** %this| rgbraw"
//% blockId=colorGetRgbRawColor
//% parts="colorsensor" //% parts="colorsensor"
//% blockNamespace=sensors //% blockNamespace=sensors
//% this.fieldEditor="ports" //% this.fieldEditor="ports"
//% weight=98 //% weight=98
//% group="Color Sensor" //% group="Color Sensor"
//% blockGap=8 //% blockGap=8
getRgbRaw() { rgbRaw(): number[] {
this.setMode(ColorSensorMode.RgbRaw); this.setMode(ColorSensorMode.RgbRaw);
return [this.getNumber(NumberFormat.UInt16LE, 0), this.getNumber(NumberFormat.UInt16LE, 2), this.getNumber(NumberFormat.UInt16LE, 4)]; return [this.getNumber(NumberFormat.UInt16LE, 0), this.getNumber(NumberFormat.UInt16LE, 2), this.getNumber(NumberFormat.UInt16LE, 4)];
} }
@ -249,8 +249,13 @@ namespace sensors {
//% group="Color Sensor" //% group="Color Sensor"
light(mode: LightIntensityMode) { light(mode: LightIntensityMode) {
this.setMode(<ColorSensorMode><number>mode) this.setMode(<ColorSensorMode><number>mode)
switch(mode) {
case LightIntensityMode.ReflectedRaw:
return this.reflectedLightRaw();
default:
return this.getNumber(NumberFormat.UInt8LE, 0) return this.getNumber(NumberFormat.UInt8LE, 0)
} }
}
/** /**
* Gets the ambient light * Gets the ambient light
@ -271,7 +276,8 @@ namespace sensors {
/** /**
* Gets the raw reflection light value * Gets the raw reflection light value
*/ */
getRefRaw() { //%
reflectedLightRaw(): number {
this.setMode(ColorSensorMode.RefRaw); this.setMode(ColorSensorMode.RefRaw);
return this.getNumber(NumberFormat.UInt16LE, 0); return this.getNumber(NumberFormat.UInt16LE, 0);
} }

View File

@ -2,7 +2,7 @@
"name": "pxt-ev3", "name": "pxt-ev3",
"version": "1.1.2", "version": "1.1.2",
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode", "description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
"private": true, "private": false,
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
"education", "education",