adafruit / Adafruit_CircuitPython_NeoPixel

CircuitPython drivers for neopixels.
MIT License
302 stars 98 forks source link

added setup instructions for sudo-less RPi usage #146

Closed Kasperror closed 1 year ago

Kasperror commented 1 year ago

Resolved the problem when using the SPI MOSI (GPIO 10) would result in unexpected behaviour when sending signals for a long periods. Turns out that Serial interface/ Serial port hardware has to be enabled otherwise the communication on SPI was being cut after few seconds. resolves #104 resolves #72 resolves #58

Kasperror commented 1 year ago

I think this should make pylint happy. Thanks for adding the usage example!

I checked the code (only in github editor to be fair) and there are no whitespaces left after applying your suggestions but the tests still fail. I can't spot the actual problem. The github preview displays whole README.rst correctly after applying changes. The tests are not too verbose about exact lines. Do you have access to more detailed logs of Build CI?

powerjungle commented 1 year ago

When I tried this method it works, but I have a weird issue, which I'm not sure if it's from my setup. The moment I hooked up to the GPIO10 pin and started using it, my data seems corrupted. The LEDs light up with the wrong colors and some are flashing when they shouldn't be. I turned on SPI and Serial Port as instructed in the commit and I rebooted. I'm using a big power supply which should be able to handle 8 amps, which should be more then enough for my 50 LEDs. I tested on a lower brightness and same thing. It's always consistently the same wrong colors too. For example when I run this:

import board
import neopixel
pixels = neopixel.NeoPixel(board.D10, 50)
pixels.fill((255, 255, 255))

They all light up as orange instead of white. When, I try turning them on one by one to blue, they first turn pink and then blue. The weird part is, it's always these colors, it doesn't randomly change from white to pink for example, only to orange.

This is my setup: https://learn.adafruit.com/assets/64121

I think it might be some timing issue, because when I set auto_write=False and then add a delay between fill() and show() all LEDs turn off as they should, without the delay, the first one remains on light up as red, even though I didn't set it to red.

As far as I remember, the issue happened, the moment I switched to the new pin and started using this method, when I tried going back to the old method using root and GPIO18, the issue persisted. That's what made me think it's something from my setup, but I can't think of why it would be working normally before and now just crap out randomly. Maybe I messed something up in the hardware, hope I didn't kill my GPIO lol.

I tried setting spidev.bufsiz=32768 in /boot/cmdline.txt just in case, but no difference. I got this info from here: https://pypi.org/project/rpi-ws281x

dhalbert commented 1 year ago

@powerjungle Did you ever get the correct colors? Do you have RGBW NeoPixels instead of RGB ones? Do you have the part number for the strip you have?

powerjungle commented 1 year ago

@dhalbert yeah like I said:

but I can't think of why it would be working normally before and now just crap out randomly

They were working normally before that. I changed between RGBW and RGB when using the module, but it didn't make a difference.

These are the ones I have: https://www.amazon.de/dp/B06XD72LYM?psc=1&ref=ppx_yo2ov_dt_b_product_details

It might be that they're just defective or that I fried something, but it was just a weird coincidence with switching to this method, so I wanted to mention just in case. There might be some configuration that is needed on the raspberry or the python module, no idea. Only way to be sure is to get new lights, but right now I can't, so I'm throwing this out there, in case anyone has ideas what the cause might be, if it's something obvious that I'm missing.

Kasperror commented 1 year ago

Make sure you have a common GND for LED's and RPi board.

FoamyGuy commented 1 year ago

I cloned this locally and ran pre-commit to get the formatting fixed. I don't have permission to commit to this branch in the PR though so I cannot update it here.

This link should go to a comparison that shows the difference needed to make the formatting check happy. https://github.com/Kasperror/Adafruit_CircuitPython_NeoPixel/compare/patch-1...FoamyGuy:Adafruit_CircuitPython_NeoPixel:foamyguy-kasperror-patch-1

@Kasperror if you make that change in your branch and push a new commit with it then it should update here and pass the actions I believe.

I'm also going to open a new PR with this change made on my own fork of your branch just in case you don't have time to get back to this so that we can still move it forward in the Adafruit fork.

Kasperror commented 1 year ago

Thanks to @FoamyGuy 's research the code finally managed to pass the tests. If you may, please merge the changes so others can use the led rings without sudo without adding another "issue"

Kasperror commented 1 year ago

@tannewt could you look into merging this? The tests pass now thanks to @FoamyGuy