0

Is it possible to change the brightness on the fly for Adafruit_CircuitPython_NeoPixel ?

It seems to be possible in a C library but no in python.

Thanks, mcb

eemceebee
  • 2,656
  • 9
  • 39
  • 49

2 Answers2

0

neopixel derives from Pypixelbuf, and inherits a brightness property from that module. Did you try it?

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
  • Well, I only can set the brightness when I initiate NeoPixel: pixels = neopixel.NeoPixel( pixel_pin, pixel_width * pixel_height, brightness=0.1, auto_write=False, ) and I use PixelFramebuffer. Here I could not find any brightness setting – eemceebee Nov 24 '21 at 16:23
  • Did you try `pixels.brightness = 0.75`? I can't try this, but looking at the base class source, that should work. – Tim Roberts Nov 24 '21 at 18:28
0

You have to deinit() the pixel object and reinitialize it with the new brightness.

pixel.deinit()
pixel = neopixel.NeoPixel(pixel_pin, number_pixel, brightness=new brightness)
Maria K
  • 1,491
  • 1
  • 3
  • 14
Sinai
  • 1
  • 1