Issue
I am using this python package to control a led strip. Using PWM everything worked perfectly fine but it didn't allow me to run the script without sudo which is why I switched over to using SPI.
Now I get this weird behaviour where suddenly the entire led strip lights up but in kind of a gradient:
The strip is connected to GND, 5V, and GPIO10 / MOSI / Pin 19.
Example usage of the Strip:
#strip = Adafruit_NeoPixel(led_count, led_pin, led_freq_hz, led_dma, led_invert, led_brightness, led_channel)
strip = Adafruit_NeoPixel(110, 10, 800000, 10, False, 255, 0)
# PWM would have GPIO 18 as led_pin
# strip = Adafruit_NeoPixel(110, 18, 800000, 10, False, 255, 0)
strip.begin()
strip.setPixelColor(0, Color(255, 255, 255))
strip.show()
I also implemented a draw-like mode where I can set the color for every specific led. Around every other color-setting-request this error occurs. I also set the entire strip on the same color to check if maybe the gradient has to do with power, but it works just fine ...
Solution
My Solution: Don't use SPI
After hours of try and error, I decided to continue using PWM As this required the script to run with root, I outsourced the led controller in its own python program and used interprocess communication to get the needed information from the flask app to the led controller.
This controller program is automatically started as a system service - except for this service crashing at midnight this works fine.
Answered By - ningelsohn Answer Checked By - Senaida (WPSolving Volunteer)