craftbeerpi3
craftbeerpi3 copied to clipboard
Switching GPIOPWM to on tries to create a new PWM object
Every time GPIOPWM.on() is called, it tries to create a new PWM.GPIO object, attached to the actor's GPIO pin (line 56 of modules/base_plugins/gpio_actor/init.py). This raises an exception as PWM.GPIO does not like to create a new object attached to a pin that has already been assigned, and requires that the control be pressed a second time to switch the actor on.
The simple way to prevent this is to check whether the PWM object exists with if self.p is None:
and only try create the PWM object if it doesn't already exist.