Pycom WyPy 3.0 onboard RGB LED [WS2812] - UPDATED & BUG REPORT


#1

I have been trying to get the NeoPixel fitted on the PyCom board to behave.
Have tried various things including this …

class rgbled:
def _ _ init _ _(self):
self.leds = neopixel.LedStrip(neo_pin, 1) # neo_pin = D0
self.fadeAnimation = [
# half cycle sine
0,
0.130526,
0.258819,
0.382683, …

def doHeartBeat(self, delay, exit = False):
    step = 1
    while True:
        if exit:
            self.leds.clear()
            self.leds.on()
            break
        hue = int(48*(self.fadeAnimation[step]))
        self.leds.set(0, hue , 0, hue)
        self.leds.on()
        step += 1
        if step >= len(self.fadeAnimation):
            step = 0
        sleep(delay)

def startHeartBeat(self, delay = 100):
    print("Start HeartBeat")
    thread(self.doHeartBeat, delay)

Which is based on one of the examples given in the worldsemi library wiki.
The HeartBeat function is running in it’s own thread although I have tried running it directly in main.py where the behaviour is much the same.

It works [kind of] except that at fairly regular intervals the data stream going to the WS2812 is disturbed resulting in a very bright green flash. [as you can see in this example I am only using Red and Blue LEDs]

I have also tried just setting the LED to a static color and very often the result [after leds.on()] is bright green regardless of the values that I set. leds.clear() does not appear to work at all but I haven’t investigated this yet.

Looking at the pin D0 directly using an oscilloscope I can see that at the time of the disturbance the data appears corrupted and some of the pin transitions happen faster than they should. I assume there is some bit banging/timer thing going on somewhere.

There seems to be some dependence on the actual data value which effect the interval at which the disturbance occurs although I havent been able to make sense of it. i.e. if I change the multiplier in the line that calculates hue [currently 48] then the pattern of green flashes change. With the code as shown the disturbance happens at [suspiciously] about once per second.

So …
Is there anything going on within Zerynth that reserves or overrides access to this LED ??
[e.g. in the Pycom/PyMAKR world you first have to disable the system heartbeat before you can take control of the LED]. When I am running other code on the device there doesn’t appear to be any activity on the LED but I havent actually looked at the pin with the 'scope.

Has anyone else tried using this specific LED together with the [fairly new] worldsemi library with any success ??


#2

OK Update on this.
Sorry it took so long but I didnt have any other WS2812’s to try…

So if I attach a short strip of these [16] on a completely different pin [I tried a few but now on D5].
The strange behaviour still applies to the very first device on the chain … so a “leds.set(0,r,g,b)” often produces a bright green output on the first led in the chain.
If I use the next device [or any of the others] everything appears to work OK.

Fairly certain this has to be a bug in the WS2812 library code probably relating to ESP32.