support for rgb led in simulator
This commit is contained in:
@ -4,31 +4,31 @@
|
||||
enum Colors {
|
||||
//% blockIdentity=basic.color
|
||||
//% block=red
|
||||
Red = 0xFF0000,
|
||||
Red = 0x00FF0000,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=orange
|
||||
Orange = 0xFFA500,
|
||||
Orange = 0x00FFA500,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=yellow
|
||||
Yellow = 0xFFFF00,
|
||||
Yellow = 0x00FFFF00,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=green
|
||||
Green = 0x00FF00,
|
||||
Green = 0x0000FF00,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=blue
|
||||
Blue = 0x0000FF,
|
||||
Blue = 0x000000FF,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=indigo
|
||||
Indigo = 0x4b0082,
|
||||
Indigo = 0x004b0082,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=violet
|
||||
Violet = 0x8a2be2,
|
||||
Violet = 0x008a2be2,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=purple
|
||||
Purple = 0xFF00FF,
|
||||
Purple = 0x00FF00FF,
|
||||
//% blockIdentity=basic.color
|
||||
//% block=white
|
||||
White = 0xFFFFFF
|
||||
White = 0xFF00000
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,16 +36,6 @@ enum Colors {
|
||||
*/
|
||||
//% color=#0078D7 weight=100
|
||||
namespace basic {
|
||||
|
||||
/**
|
||||
* Sets the color on the build-in LED
|
||||
*/
|
||||
//% blockId=device_set_led_color block="set led to %color=color_id" icon="\uf00a"
|
||||
//% weight=50
|
||||
export function setLedColor(color: number) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the color name to a number
|
||||
*/
|
||||
@ -53,4 +43,17 @@ namespace basic {
|
||||
export function color(c: Colors): number {
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts red, green, blue channels into a RGB color
|
||||
* @param red value of the red channel between 0 and 255. eg: 255
|
||||
* @param green value of the green channel between 0 and 255. eg: 255
|
||||
* @param blue value of the blue channel between 0 and 255. eg: 255
|
||||
* @param white value of the white channel between 0 and 255. eg: 0
|
||||
*/
|
||||
//% weight=1
|
||||
//% blockId="core_rgb" block="red %red|green %green|blue %blue|white %white"
|
||||
export function rgbw(red: number, green: number, blue: number, white:number): number {
|
||||
return ((white & 0xFF) << 24) | ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | (blue & 0xFF);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user