vitormhenrique / OctoPrint-Enclosure

OctoPrint Enclosure Plugin
GNU General Public License v3.0
396 stars 202 forks source link

WS2812B can't control brightness #311

Open Piranit opened 4 years ago

Piranit commented 4 years ago

Hi. I'm using Raspberry Pi 4 Model B 4GB I connected Din pin to 18 GPIO. LED works, I can change color. But I can't control brightness. Even when in settings I set brightness parameter to zero, LED still shining at the maximum brightness. Can anybody suggest something?

Piranit commented 4 years ago

Today I have tested with strandtest.py from rpi_ws281x library and the changing of brightness works perfect. But why doesn't it work from plugin?

LED_COUNT      = 70      # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 200     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53

image

Setting brightness to 200 makes no effect, same brightness as on 255 point :( Also no effect for any other brightness point, even at 0 point, LED is still shining at the maximum brightness

viatsyshyn commented 4 years ago

Hi, have similar problem

blackote commented 4 years ago

Hi Guys, so I just had to re-setup my Pi using the RPi 4. Just make sure to follow the Neopixel instructions on the readme. then reference to Issue number 172 https://github.com/vitormhenrique/OctoPrint-Enclosure/issues/172#issuecomment-410864599

adding the DMA 10

Piranit commented 4 years ago

@blackote thanks for your time, but the problem is related to BRIGHTNESS control. The solution of the problem you've recommended won't help. Why?

I've already figured out the problem, the problem is that the parameter LED_BRIGHTNESS is not used anywhere at all. You can check it out here and LED_DMA is already working well, so you don't need to create the LED_DMA variable by yourself.

How to solve the problem with the brightness? You have to replace strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT) in octoprint_enclosure / neopixel_direct.py with strip = Adafruit_NeoPixel (LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS) Then brightness control will work.

I've tested this way and everything works fine. I think now it's easy to understand, that the LED_BRIGHTNESS parameter haven't been used and that has created the problem.

I've made a pull request about this problem, hope that it'd be taken into account soon.