Commit ea6bb08d authored by Pietro Saccardi's avatar Pietro Saccardi

PWMLed: better logging, building LED on activation.

parent 23242719
......@@ -18,19 +18,30 @@ class PWMLedPlugin(PluginProcessBase):
self._bcm_pin = SETTINGS.pwmled.get('bcm_pin', default=None, cast_to_type=int, ge=0, le=27, allow_none=True)
self._frequency = SETTINGS.pwmled.get('frequency', default=100, cast_to_type=int, ge=10, le=10000)
self._pwmled = None
self._active = False
def _rebuild_pwmled(self):
old_value = 0.
if self._pwmled is not None:
old_value = self._pwmled.value
if not self._active or self._bcm_pin is None:'Disabling PWM led.')
old_value = self._pwmled.value
self._pwmled = None
if self._bcm_pin is not None:
_log.debug('Rebuilding PWM led on pin %d with frequency %d.', self._bcm_pin, self._frequency)
if self._bcm_pin is not None and self._active:'Rebuilding PWM led on pin %d with frequency %d.', self._bcm_pin, self._frequency)
self._pwmled = PWMLED(self.bcm_pin, frequency=self.frequency, initial_value=old_value)
_log.debug('Disabled PWM led.')
def __enter__(self):
self._active = True
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self._active = False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment