From 75e3dfc6dd357ded8d4c7dda5f77b8d04e3e3eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=8D=A3?= <1595243018@qq.com> Date: Fri, 8 Nov 2024 14:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20maqueenPlusV2.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maqueenPlusV2.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/maqueenPlusV2.ts b/maqueenPlusV2.ts index 9f31377..a71a60b 100644 --- a/maqueenPlusV2.ts +++ b/maqueenPlusV2.ts @@ -303,7 +303,7 @@ namespace maqueenPlusV2 { switch(eline){ case MyEnumLineSensor.SensorR2: pins.i2cWriteNumber(I2CADDR, ADC0_REGISTER, NumberFormat.Int8LE); - let adc0Buffer = pins.i2cReadBuffer(I2CADDR, 1); + let adc0Buffer = pins.i2cReadBuffer(I2CADDR, 2); data = adc0Buffer[1] << 8 | adc0Buffer[0] break; case MyEnumLineSensor.SensorR1: @@ -413,7 +413,15 @@ namespace maqueenPlusV2 { export function ledRange(from: number, to: number): number { return ((from) << 16) + (2 << 8) + (to); } - + /** + * Gets the RGB value of a known color + */ + //% weight=2 blockGap=8 + //% blockId="neopixel_colors" block="%color" + //% advanced=true + export function colors(color: NeoPixelColors): number { + return color; + } /** * Set the color of the specified LEDs * @param index , eg: 1 @@ -421,8 +429,8 @@ namespace maqueenPlusV2 { //% weight=60 //% index.min=0 index.max=3 - //% block="RGB light |%index show color|%rgb" - export function setIndexColor(index: number, rgb: NeoPixelColors) { + //% block="RGB light |%index show color|%rgb=neopixel_colors" + export function setIndexColor(index: number, rgb: number) { let f = index; let t = index; let r = (rgb >> 16) * (_brightness / 255); @@ -452,8 +460,8 @@ namespace maqueenPlusV2 { */ //% weight=60 - //% block=" RGB show color |%rgb" - export function showColor(rgb: NeoPixelColors) { + //% block=" RGB show color |%rgb=neopixel_colors" + export function showColor(rgb: number) { let r = (rgb >> 16) * (_brightness / 255); let g = ((rgb >> 8) & 0xFF) * (_brightness / 255); let b = ((rgb) & 0xFF) * (_brightness / 255);