add color handling for LED

This commit is contained in:
Matthias L. Jugel 2016-10-12 17:54:25 +02:00
parent 8b1b1bb869
commit 7102eddc0b
4 changed files with 12 additions and 12 deletions

View File

@ -13,7 +13,7 @@ namespace basic {
//% weight=50 //% weight=50
void setLedColor(int color) { void setLedColor(int color) {
if (!color) { if (!color) {
uBit.rgb.Off(); uBit.rgb.off();
return; return;
} }
@ -22,9 +22,7 @@ namespace basic {
int g = (color >> 8) & 0xFF; int g = (color >> 8) & 0xFF;
int b = (color) & 0xFF; int b = (color) & 0xFF;
uBit.rgb.Set_Color(r,g,b,w); uBit.rgb.setColour(r,g,b,w);
uBit.rgb.On();
uBit.rgb.Send_to_LED();
} }
/** /**

6
libs/core/dal.d.ts vendored
View File

@ -190,12 +190,6 @@ declare const enum DAL {
MICROBIT_SERIAL_EVT_TX_EMPTY = 2, MICROBIT_SERIAL_EVT_TX_EMPTY = 2,
MICROBIT_UART_S_EVT_TX_EMPTY = 3, MICROBIT_UART_S_EVT_TX_EMPTY = 3,
// built/yt/yotta_modules/microbit-dal/inc//drivers/CalliopeRGB.h // built/yt/yotta_modules/microbit-dal/inc//drivers/CalliopeRGB.h
RGB_LED_DEFAULT_GREEN = 0,
RGB_LED_DEFAULT_RED = 0,
RGB_LED_DEFAULT_BLUE = 0,
RGB_LED_DEFAULT_WHITE = 0,
RGB_KEEP_VALUE = -1,
RGB_LED_MAX_INTENSITY = 50,
// built/yt/yotta_modules/microbit-dal/inc//drivers/CalliopeSoundMotor.h // built/yt/yotta_modules/microbit-dal/inc//drivers/CalliopeSoundMotor.h
CALLIOPE_SM_DEFAULT_DUTY_M = 50, CALLIOPE_SM_DEFAULT_DUTY_M = 50,
CALLIOPE_SM_DEFAULT_DUTY_S = 100, CALLIOPE_SM_DEFAULT_DUTY_S = 100,

View File

@ -43,8 +43,7 @@
"microbit-dal": { "microbit-dal": {
"bluetooth": { "bluetooth": {
"enabled": 0 "enabled": 0
}, }
"debug": 1
} }
} }
} }

View File

@ -1,3 +1,12 @@
basic.setLedColor(Colors.Blue)
basic.pause(500)
basic.setLedColor(Colors.Red)
basic.pause(500)
basic.setLedColor(Colors.Green)
basic.pause(500)
basic.setLedColor(0);
basic.setLedColor(Colors.Violet)
basic.pause(100)
led.plot(0, 0) led.plot(0, 0)
basic.pause(1000); basic.pause(1000);
basic.forever(() => { basic.forever(() => {