Skip to content

Commit

Permalink
更新 maqueenPlusV2.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
LinDong88 committed Nov 8, 2024
1 parent 7cd268b commit 75e3dfc
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions maqueenPlusV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -413,16 +413,24 @@ 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
*/

//% 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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 75e3dfc

Please sign in to comment.