Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

NeoPixel library for micropython?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

NeoPixel library for micropython?

by chipnod2020 on Fri Apr 09, 2021 8:53 am

I've been trying to find how to install the neopixel library for my Raspberry Pi Pico. From what I have been reading and finding, I am not sure if it exists.

My question: Is there a way to load neopixel libraries into the Pico, or since the processor is not compatible it doesn't exist yet?

chipnod2020
 
Posts: 29
Joined: Wed Jul 15, 2020 9:59 am

Re: NeoPixel library for micropython?

by dastels on Fri Apr 09, 2021 10:34 am

I don't know about support for MicroPython, but CircuitPython 6.2.0 runs on the Pico: https://circuitpython.org/board/raspberry_pi_pico/

Dave

dastels
 
Posts: 6478
Joined: Tue Oct 20, 2015 3:22 pm

Re: NeoPixel library for micropython?

by chipnod2020 on Fri Apr 09, 2021 10:51 am

Hey ya Dastels!

I have tried CircuitPython and the issue then becomes CP doesn't support interupts. For example, here is my micropython script.

Code: Select all | TOGGLE FULL SIZE
import utime
from machine import Pin, PWM

### Pulse Cannons
# Pins
btn_pc = Pin(16, Pin.IN, Pin.PULL_UP) # GPIO 3 Physical pin 5
led_pc = Pin(17, Pin.OUT) # GPIO 4 Physical pin 6
# Variables
PC_blinkF = 100 # How long between flashes
PC_blinkT = 10 # How many flashes do you want times 2: 5 flashes = 10

def debounce(pin):
    prev = None
    for _ in range(32):
        current_value = pin.value()
        if prev != None and prev != current_value:
            return None
        prev = current_value
    return prev

def pc_callback(pin):
    d = debounce(pin)
    if d == None:
        return
    elif not d:
        for i in range(PC_blinkT):
            led_pc.toggle()
            utime.sleep_ms(PC_blinkF)

btn_pc.irq(trigger=Pin.IRQ_FALLING, handler=pc_callback)


so I don't think that circuitpython can support this, unless I'm a complete idiot.

chipnod2020
 
Posts: 29
Joined: Wed Jul 15, 2020 9:59 am

Re: NeoPixel library for micropython?

by dastels on Fri Apr 09, 2021 11:23 am

You're right, CircuitPython doesn't support interrupts (yet anyway). What does that have to do with NeoPixels?

Dave

dastels
 
Posts: 6478
Joined: Tue Oct 20, 2015 3:22 pm

Re: NeoPixel library for micropython?

by chipnod2020 on Fri Apr 09, 2021 11:28 am

Long story... The small example I posted here is a part of a larger code that will be combined to form one giant "robot" code piece. Ultimately I'm going to have a single piece of code running on a microcontroller to light up and control Star Trek ship models. The neopixel code that I am working on would simulate this via a button push.

https://www.youtube.com/watch?v=iefJuSzKwpI

So something I've always wanted to know about *python. If you define a function, does it interfere with other functions? what timer does not block code from running?

It's very possible I'm missing something very basic as I'm still learning.

chipnod2020
 
Posts: 29
Joined: Wed Jul 15, 2020 9:59 am

Re: NeoPixel library for micropython?

by dastels on Fri Apr 09, 2021 11:59 am

CircuitPython is, to my knowledge, single threaded.

Dave

dastels
 
Posts: 6478
Joined: Tue Oct 20, 2015 3:22 pm

Re: NeoPixel library for micropython?

by chipnod2020 on Mon Apr 12, 2021 4:32 pm

I looked up a few things that may make my life easier. Circuitpython does indeed support the neopixel better for the pico. I need to learn more on multasking within circuitpython. That will remediate the irq portion of my micropython code bits.

As always, thanks for your great advise!

chipnod2020
 
Posts: 29
Joined: Wed Jul 15, 2020 9:59 am

Re: NeoPixel library for micropython?

by dastels on Mon Apr 12, 2021 5:21 pm


dastels
 
Posts: 6478
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.