rsg98 / homebridge-gpio-wpi2

Homebridge Raspberry Pi GPIO Platform (API 2) Plugin - using WiringPi as a backend
48 stars 16 forks source link

Feature Request: SoftPWM Support for Dimmable LEDs #7

Open rsg98 opened 7 years ago

rsg98 commented 7 years ago

@mv1993 request - add a Brightness characteristic that's hooked into SoftPWM - enable dimming of LEDs

rsg98 commented 7 years ago

Looks like softPWM requires one of the root WiringPi setup modes - which would go against trying to run homebridge as a non-root user.

We could look at using the built in hardware PWM on the Pi (but that only gives you two channels and kills the audio) - http://www.jumpnowtek.com/rpi/Using-the-Raspberry-Pi-Hardware-PWM-timers.html

...or using I2C to speak to a multi-channel hardware PWM board like the AdaFruit one (https://www.adafruit.com/product/815).

...or find a library other than WiringPi that offers a SoftPWM accessible to non-root

I think my preference would be one of the hardware PWM options, as we can then use the same sysfs interface to get non-root access (albeit, not via WiringPi)

mv1993 commented 7 years ago

For me two outputs are enough, but other users may need more. I also think its easier and safer to handle the request with the hardware PWM. I searched a bit on the web but I didn't find any library that supports softPWM, except wiringPi.

fivdi commented 7 years ago

pigpio supports PWM on any of GPIO0 through GPIO31 but requires root privileges.