RaspberryPiFoundation / python-build-hat

Build HAT Python library
MIT License
55 stars 19 forks source link

brightness control of lights (ID 8) affects global plimit #186

Closed arohrbacher closed 1 year ago

arohrbacher commented 1 year ago

If one uses light.brightness(x) to change the LED brightness, the code in light.py sets the global parameter plimit, therefore affecting passive motors or lights on other ports. For instance, if a light on Port A is dimmed, a running passive motor on Port B will also suddenly turn slower. The code in question is this: self._write(f"port {self.port} ; on ; plimit {brightness / 100.0}\r") I think it should rather read self._write(f"port {self.port} ; on ; set {brightness / 100.0}\r") this only sets the PWM value for the port the light is connected to...

chrisruk commented 1 year ago

Thanks for this report! Will look into this next week

mutesplash commented 1 year ago

This also causes the Matrix to glitch and fail. Is there any way to get a per-port plimit in the firmware?

chrisruk commented 1 year ago

Good question @mutesplash , it might be down to how the hardware works, will find out if per-port is possible

chrisruk commented 1 year ago

I've updated the code to use set, rather than plimit. I'm going to test a new firmware soon that will enable a per port plimit, which will be useful for motors.