From bbc15ce307d97fda20cfc285902b165517d3c3c3 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:56:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20maqueen.ts,=20=5Flocales/z?= =?UTF-8?q?h-cn/maqueen-strings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _locales/zh-cn/maqueen-strings.json | 4 ++-- maqueen.ts | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/_locales/zh-cn/maqueen-strings.json b/_locales/zh-cn/maqueen-strings.json index 32ee52d..aa9d764 100644 --- a/_locales/zh-cn/maqueen-strings.json +++ b/_locales/zh-cn/maqueen-strings.json @@ -54,8 +54,8 @@ "Maqueen_V5.NeoPixelColors.White|block": "白", "Maqueen_V5.NeoPixelColors.Black|block": "黑", "Maqueen_V5.bottomSetBrightness|block": "设置底部RGB亮度为|%brightness", - "Maqueen_V5.bottomShowColor|block": "底部RGB显示颜色|%rgb", - "Maqueen_V5.bottomSetColor|block": "底部RGB 灯|%index 显示颜色|%rgb", + "Maqueen_V5.bottomShowColor|block": "底部RGB显示颜色|%rgb=neopixel_colors", + "Maqueen_V5.bottomSetColor|block": "底部RGB 灯|%index 显示颜色|%rgb=neopixel_colors", "Maqueen_V5.bottomLedRange|block": "底部RGB范围从|%from 到|%to", "Maqueen_V5.bottomRgb|block": "红|%r绿|%g蓝|%b", "Maqueen_V5.bottomLedRainbow|block": "设置底部RGB显示彩虹色从|%startHue 到|%endHue", diff --git a/maqueen.ts b/maqueen.ts index 86f658e..0d25938 100644 --- a/maqueen.ts +++ b/maqueen.ts @@ -1176,17 +1176,25 @@ namespace Maqueen_V5 { export function bottomLedRange(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 + * @param index , eg: 0 */ //% weight=60 - //% index.min=0 index.max=3 - //% block="RGB light |%index show color|%rgb" + //% index.min=0 index.max=3 index.defl=0 + //% block="RGB light |%index show color|%rgb=neopixel_colors" //% group="Maqueen_v5" - export function bottomSetColor(index: number, rgb: NeoPixelColors) { + export function bottomSetColor(index: number, rgb: number) { let f = index; let t = index; let r = (rgb >> 16) * (_brightness / 255); @@ -1216,9 +1224,9 @@ namespace Maqueen_V5 { */ //% weight=60 - //% block=" RGB show color |%rgb" + //% block=" RGB show color |%rgb=neopixel_colors" //% group="Maqueen_v5" - export function bottomShowColor(rgb: NeoPixelColors) { + export function bottomShowColor(rgb: number) { let r = (rgb >> 16) * (_brightness / 255); let g = ((rgb >> 8) & 0xFF) * (_brightness / 255); let b = ((rgb) & 0xFF) * (_brightness / 255);