microsoft / pxt-neopixel

A Neo-Pixel package for pxt-microbit
https://makecode.microbit.org/pkg/microsoft/pxt-neopixel
MIT License
58 stars 141 forks source link

NeoPixelColors is not correctly compared in the logic block. #44

Closed GomiHgy closed 4 years ago

GomiHgy commented 5 years ago

When I executed the source code below, I guessed that the LED will turn on in red because LEDColor = neopixel.colors(NeoPixelColors.Black) at line 9. However, the LED turned green.

function setLED (color: number) {
    strip.showColor(color)
    LEDColor = color
}
let LEDColor = 0
let strip: neopixel.Strip = null
strip = neopixel.create(DigitalPin.P0, 3, NeoPixelMode.RGB_RGB)
setLED(neopixel.colors(NeoPixelColors.Black))
if (LEDColor == neopixel.colors(NeoPixelColors.Red)) {
    setLED(neopixel.colors(NeoPixelColors.Green))
} else {
    setLED(neopixel.colors(NeoPixelColors.Red))
}

WS000125 Source : https://makecode.microbit.org/_Pdf0pyWJg01i

However, when I removed the "else" part at line 11, the LED did not light up in red somehow. WS000124 Source : https://makecode.microbit.org/_Kmv4wkM7h718

I am wondering if this phenomenon is an implementation error or a defect.