I have been trying to get the NeoPixel fitted on the PyCom board to behave.
Have tried various things including this …
def _ _ init _ _(self):
self.leds = neopixel.LedStrip(neo_pin, 1) # neo_pin = D0
self.fadeAnimation = [
# half cycle sine
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.
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 ??