[ADAFRUIT_F405_EXPRESS] neopixel port advice
[ADAFRUIT_F405_EXPRESS] neopixel port advice
I have one of these:
Adafruit STM32F405 Feather Express
https://learn.adafruit.com/adafruit-stm ... s/overview
It has a red LED and a Neopixel.
If I load CircuitPython onto the board, the neopixel module works.
Am I correct that MicroPython currently has no support for the Neopixel?
If so, has anyone started?
TIps from #CircuitPython:
You could copy how we do it (low-level bitbanging, or, on nRF52, we use PWM).
ESP32 has special-purpose hw that is ideal for it). See the low-level neopixel_write module in ports/*/common-hal/neopixel_write
making digitalio calls may be too slow
The nRF boards use PWM (much more memory hungry) because turning off interrupts like neopixel_write does is not good for BLE timing.
My plan is to copy the files around and try to change as little as possible.
Adafruit STM32F405 Feather Express
https://learn.adafruit.com/adafruit-stm ... s/overview
It has a red LED and a Neopixel.
If I load CircuitPython onto the board, the neopixel module works.
Am I correct that MicroPython currently has no support for the Neopixel?
If so, has anyone started?
TIps from #CircuitPython:
You could copy how we do it (low-level bitbanging, or, on nRF52, we use PWM).
ESP32 has special-purpose hw that is ideal for it). See the low-level neopixel_write module in ports/*/common-hal/neopixel_write
making digitalio calls may be too slow
The nRF boards use PWM (much more memory hungry) because turning off interrupts like neopixel_write does is not good for BLE timing.
My plan is to copy the files around and try to change as little as possible.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
If you are confident in understanding how MP works you could implement the Neoplixel driver I made using a timer interupt to send the data. See here https://github.com/OutOfTheBots/STM32_NEOpixels_timer
It has been tested on a STM32F407 there might be a few small tweeks for it to do eactly what you want it to do.
Edit
I have just had a close look at the schematics for that board and it seems the neopixel is connected to pin PC0 which doesn't have a timer attached to it so it can't be driven by a timer. In fact when I look at that pin it doesn't have a SPI either so SPI method can't be used either. It has to be driven as a GPIO pin bit bang getting timing right by using NOPs
It has been tested on a STM32F407 there might be a few small tweeks for it to do eactly what you want it to do.
Edit
I have just had a close look at the schematics for that board and it seems the neopixel is connected to pin PC0 which doesn't have a timer attached to it so it can't be driven by a timer. In fact when I look at that pin it doesn't have a SPI either so SPI method can't be used either. It has to be driven as a GPIO pin bit bang getting timing right by using NOPs
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
Thanks for looking into this.
So A) it has to be bit banged, but B) that is how CircuitPython does it, so C) the code and timing are all there, right?
(I did load up CP and do a few tests to make sure it worked.)
So A) it has to be bit banged, but B) that is how CircuitPython does it, so C) the code and timing are all there, right?
(I did load up CP and do a few tests to make sure it worked.)
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
I got the neopixel on the STM32F405 Express to work. I checked out PR #5318 and then rebased to the latest master. You'll need to rebuild the firmware. So something like this:
You should now have a branch in your local repository called neopixel which is based off the latest master. Put your board in DFU mode (connect B0 to 3.3v and reset the board) and flash your custom firmware using:You can verify that you have the correct firmware by verifying that there is a neopixel_write in the pyb module. At the REPL you can type pyb.neo and press TAB and it should expand to neopixel_write (or do a dir(pyb) and see if neopixel_write is there).
You'll find a neopixel.py file in the micropython/drivers/neopixel directory. Copy it to your board (I put it in the /flash directory using rshell). Then from the REPL you can do: and the neopixel should come on as a dim red.
The 3-tuple is (R,G,B) where each color can vary from 0-255. I found anything above 10 to be rather bright. You'll always use np[0] since there is only a single neopixel in the chain.
Code: Select all
cd micropython
git checkout master
git pull
git checkout dee49682d690898dc58397e2975e3944aa2d9d61
git checkout -b neopixel
git rebase master
git submodule update --init --recursive
cd ports/stm32
make BOARD=ADAFRUIT_F405_EXPRESS
Code: Select all
make BOARD=ADAFRUIT_F405_EXPRESS deploy
You'll find a neopixel.py file in the micropython/drivers/neopixel directory. Copy it to your board (I put it in the /flash directory using rshell). Then from the REPL you can do:
Code: Select all
>>> import neopixel
>>> np = neopixel.NeoPixel(pyb.Pin('NEOPIXEL'), 1)
>>> np[0] = (1, 0, 0)
>>> np.write()
The 3-tuple is (R,G,B) where each color can vary from 0-255. I found anything above 10 to be rather bright. You'll always use np[0] since there is only a single neopixel in the chain.
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
Thats great, so should this make its way into a release at some stage?
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
I expect it will eventually. @dpgeorge created the driver. You can view the PR here: https://github.com/micropython/micropython/pull/5318
so I suspect it's just a matter of time.
so I suspect it's just a matter of time.
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
Didn't quite work for me:dhylands wrote: ↑Sat Feb 20, 2021 1:51 amCode: Select all
cd micropython git checkout master git pull git checkout dee49682d690898dc58397e2975e3944aa2d9d61 git checkout -b neopixel git rebase master git submodule update --init --recursive cd ports/stm32 make BOARD=ADAFRUIT_F405_EXPRESS
Code: Select all
❯ git checkout dee49682d690898dc58397e2975e3944aa2d9d61
fatal: reference is not a tree: dee49682d690898dc58397e2975e3944aa2d9d61
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
I assume this is because commit dee49682d690898dc58397e2975e3944aa2d9d61 is in @dpgeorge's fork of micropython. I would have cloned this repo but it seems to be 1227 commits behind micropython:master. Not sure what to do.
Re: [ADAFRUIT_F405_EXPRESS] neopixel port advice
Whoops. Sorry about that.
Try this command:
That should replace these 2 commands:
I actually use a script called git-pr which I got from here: https://gist.github.com/jhnns/d654d9d6da6d3b749986
If you put that in your PATH and make it executable, then you can replace the above with:
Try this command:
Code: Select all
git fetch -fu origin pull/5318/head:neopixel
git checkout neopixel
Code: Select all
git checkout dee49682d690898dc58397e2975e3944aa2d9d61
git checkout -b neopixel
If you put that in your PATH and make it executable, then you can replace the above with:
Code: Select all
git pr 5318