Disclaimer: This isn’t actually a fully fledged guide as of now, I haven’t even gotten anything running yet. I will edit as I go along.
Intro
I’m currently in the process of getting a project ported over from Raspberry Pi to the Duo. For this project, I am using a Neopixel stick. I’m hoping that getting all the Python libraries that work on the Pi installed will “just work”, but I’m guessing I’m going to prove myself wrong in a bit.
Everything here for install is somewhat based on this guide by Adafruit.
If anyone has Neopixels and wants to follow along at home:
(Recommended for installation process: enable swap)
1. Add to your defconfig file:
# Extra packages for Neopixel support
BR2_PACKAGE_PYTHON_SETUPTOOLS=y
BR2_PACKAGE_PYTHON_RPI_WS281X=y
BR2_PACKAGE_PYTHON_PYYAML=y
BR2_PACKAGE_PYTHON_REQUESTS=y
BR2_PACKAGE_PYTHON_PEXPECT=y
BR2_PACKAGE_PYTHON_PROTOBUF=y
BR2_PACKAGE_PYTHON_PYQRCODE=y
Then build the image and do whatever configuration is necessary before continuing like swap, network config, etc.
When running the example code I got what I expected I would get
File "/root/neopixel.py", line 1, in <module>
import board
File "/usr/lib/python3.9/site-packages/board.py", line 378, in <module>
raise NotImplementedError(
NotImplementedError:
Adafruit-PlatformDetect version 3.57.0 was unable to identify the board and/or
microcontroller running the Linux platform. Please be sure you
have the latest packages by running:
'pip3 install --upgrade adafruit-blinka adafruit-platformdetect'
If you are running the latest package, your board may not yet be supported. Please
open a New Issue on GitHub at https://github.com/adafruit/Adafruit_Blinka/issues and
select New Board Request.
How are you going to write to each neopixel? I’ve been working on a solution but I can’t get the PWM to go fast enough. When I set the frequency for a 1.25um pulse time, I can’t the HLPERIOD register low enough to make the proper pulse. The value for the PERIOD register should be around 125, but in my testing I found it really needed to be around 57. This could be because I’m reading and writing the registers and maybe there is a faster way to do that. According to my math and tests I would need to be able to set HLPERIOD to a value less than 1 to make the signal longer than .5us. I’m trying to figure out how to switch the PWM clock so that the base frequency is 148.5Mhz so I have a little more wiggle room in the math. To the best of my knowledge don’t think they can be driven with spi bus as spi on the CV1008b only supports 4 to 16 bit bit writes, where as a spi driven neo pixel needs to be 3 bits; but I haven’t done all the research about SPI as I was working on a PWM strategy.
How is you project going on porting the libaray? If you need a driver I got the pwm working but it’s written in C so I don’t know if that would be any use to you.