pi_pico_neopixel icon indicating copy to clipboard operation
pi_pico_neopixel copied to clipboard

Replace PIO code with an inbuilt timer, based on https://learn.adafru…

Open mcarlson opened this issue 5 months ago • 13 comments

…it.com/intro-to-rp2040-pio-with-circuitpython/advanced-using-pio-to-drive-neopixels-in-the-background

Not really helping with the glitchiness I wonder if it's my hardware at this point?

mcarlson avatar Feb 05 '24 09:02 mcarlson

Many thanks for this.

I'll test is as soon as I get the time. I'm not sure if this would cause any backwards-compatibility problems if merged to main, but if it works okay, I believe it probably shouldn't.

blaz-r avatar Feb 05 '24 12:02 blaz-r

I believe I've addressed your comments, let me know! Keep in mind the testcase I posted requires pull 19 to work. Also, I should mention the first four pixels are white for me when I apply this change, so it's not 100% yet.

mcarlson avatar Feb 07 '24 14:02 mcarlson

Thanks for addressing the comments. I'm not sure about the white pixel problem, but it might be due to the header and trailer because the code on that link I believe does some shifting and padding to fit the DMA requirements and I'm not sure if that's same here.

blaz-r avatar Feb 07 '24 21:02 blaz-r

You were right, that packing was bogus. I've updated the PR with the new code, it works really nicely now... Thanks for your patience!

mcarlson avatar Feb 08 '24 15:02 mcarlson

Great to hear. Did the glitches also go away with this?

blaz-r avatar Feb 10 '24 10:02 blaz-r

Not entirely, though removing all interrupts and replacing with asyncio (especially Timers) seems to help a lot. It's waaay better though!

mcarlson avatar Feb 15 '24 17:02 mcarlson

Good. I'll probably have some time to review this and test next weekend. Thanks for all the effort 😄

blaz-r avatar Feb 18 '24 10:02 blaz-r

Hi, I've finally had the time to check this, really sorry for the delay. It works quite well, but I had to change some code as rotation no longer works with this code.

The other problem is that this only works for RGBW, so merging this would mean that RGB strips are no longer supported. I'm not entirely sure how to fix this, as that would require rewriting PIO program to do the pull once 24 bits are read. I'll see what I can do.

blaz-r avatar Mar 31 '24 19:03 blaz-r

Ah right I was worried about that. I’ll see if I can pass another argument in and have it only push the first 3 bytes if set. I don’t have a normal run strip to test with though, I’ll order or see if I can borrow one!

-Max

On Mon, Apr 1, 2024 at 3:18 AM, Blaž Rolih @.***(mailto:On Mon, Apr 1, 2024 at 3:18 AM, Blaž Rolih < wrote:

Hi, I've finally had the time to check this, really sorry for the delay. It works quite well, but I had to change some code as rotation no longer works with this code.

The other problem is that this only works for RGBW, so merging this would mean that RGB strips are no longer supported. I'm not entirely sure how to fix this, as that would require rewriting PIO program to do the pull once 24 bits are read. I'll see what I can do.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

mcarlson avatar Apr 01 '24 00:04 mcarlson

Thank you. I had an idea that could maybe work: when doing pull(ifempty) if we could somehow append some additional code to this ifempty and shift for 8 bits, then it should work. But at the moment I'm not sure if "ifempty" works outside pull instruction or/if it's possible to detect empty OSR.

blaz-r avatar Apr 01 '24 09:04 blaz-r

I think I figured it out. There is in fact and osre keyword that signals empty OSR 🥳

blaz-r avatar Apr 01 '24 10:04 blaz-r

When you get some time, test this code I pushed on your end (RGBW only, no need to order RGB). I tested on both RGB and RGBW and it works for me on all examples now.

blaz-r avatar Apr 01 '24 11:04 blaz-r

Looking at the new asm for ws2821, I think that the new logic introduces some additional low output, that might be problematic in some cases, although I had no issues with my strip - I'll try to fix it, but I won't be able to test for some time now.

blaz-r avatar Apr 02 '24 20:04 blaz-r