linusg / rpi-backlight

🔆 A Python module for controlling power and brightness of the official Raspberry Pi 7" touch display
https://rpi-backlight.readthedocs.io
MIT License
276 stars 32 forks source link

Pi3B+ OSError: [Errno 22] when "100" passed to backlight.brightness, value = 258 #34

Closed Martin-HiPi closed 3 years ago

Martin-HiPi commented 3 years ago

In Raspberry Pi OS 32-bit (Pi3B+) Python 3.7.3, if I set backlight.brightness = 100, the value passed to the OS is 258 and should be limited to 255. https://github.com/linusg/rpi-backlight/blob/a7b4b619f5adf16502aa7b18571098814b0bbac0/rpi_backlight/__init__.py#L96

This causes an OSError: [Errno 22] Invalid argument error. Maybe it would be a good idea to sanitize the output of _denormalize_brightness? https://github.com/linusg/rpi-backlight/blob/a7b4b619f5adf16502aa7b18571098814b0bbac0/rpi_backlight/__init__.py#L105-L106

Thanks for your time writing this useful library! EDIT: Forgot to mention library is 2.3.0

Martin-HiPi commented 3 years ago

PR created: #35

Martin-HiPi commented 3 years ago

Hi @linusg,

May I ask when you plan to release a new version of the library with the changes I submitted? I'm looking at my options at the moment as I'll ship the project possibly next week.

Thanks for your time and help! very useful!

linusg commented 3 years ago

Thanks for the ping, just released v2.4.0 here on GitHub and on PyPI. Glad you find it useful :)

Martin-HiPi commented 3 years ago

Hi @linusg

Thanks, it is very appreciated! Hopefully, our customer will appreciate our work on his screensaver! Martin, HiPi Industries, Canada