rpi-rgb-led-matrix
rpi-rgb-led-matrix copied to clipboard
[Python] Change Panel Brightness while running
Hey together,
I'm using my panels with a Raspberry Pi 4 and Joy-IT Matrix Controll Board. The panels I'm controlling with Python. The comands, what the panels have to show, I send via TCP Sockets from another Raspberry Pi. One of the comands are changing the brightness of the panels.
I've tried two ways to change the brightness:
First way was to load new options into the display-class: `def changeBrightness(self, brightness): options = RGBMatrixOptions()
options.hardware_mapping = 'regular'
options.rows = 32
options.cols = 32
options.chain_length = 6
options.parallel = 2
options.row_address_type = 0
options.multiplexing = 2
options.pwm_bits = 11
options.brightness = brightness
options.pwm_lsb_nanoseconds = 130
options.led_rgb_sequence = "RGB"
options.pixel_mapper_config = ""
options.panel_type = ""
options.gpio_slowdown = 4
#if self.args.led_show_refresh:
#options.show_refresh_rate = 1
#if self.args.led_no_hardware_pulse:
# options.disable_hardware_pulsing = True
#if not self.args.drop_privileges:
options.drop_privileges=False
self.matrix = RGBMatrix(options = options)
self.newImage(1)
self.newImage(2)`
The second way was to load the display-class new with other brightness-option: `def init(self, brightness = 80, *args, **kwargs): super(Display, self).init(*args, **kwargs) #self.matrix = SampleBase.matrix options = RGBMatrixOptions()
options.hardware_mapping = 'regular'
options.rows = 32
options.cols = 32
options.chain_length = 6
options.parallel = 2
options.row_address_type = 0
options.multiplexing = 2
options.pwm_bits = 11
options.brightness = brightness
options.pwm_lsb_nanoseconds = 130
options.led_rgb_sequence = "RGB"
options.pixel_mapper_config = ""
options.panel_type = ""
options.gpio_slowdown = 4
#if self.args.led_show_refresh:
#options.show_refresh_rate = 1
#if self.args.led_no_hardware_pulse:
# options.disable_hardware_pulsing = True
#if not self.args.drop_privileges:
options.drop_privileges=False
self.matrix = RGBMatrix(options = options)
self.mode = "startScreen"`
elif state["comand"] == "change_brightness": display = Display(state["brightness"]) display.setMode("operation") display.newImage(1) display.newImage(2)
Both ways are successfull, if i'm changing the brightness one or two times. But if I wanna do it more often, the panels are shut off and the Python-Script process is hanging off and I've to stop it with closing the terminal.
What I'm doing wrong, btw. what other way are possible to change the brightness while running?
Thank you very much
Fipschen