浏览代码

Only create new PWM.GPIO instance if one does not exist.

Fixes upstream issue #242
pull/243/head
Paul Grimes 5 年前
父节点
当前提交
0cf50e9de9
共有 1 个文件被更改,包括 4 次插入6 次删除
  1. +4
    -6
      modules/base_plugins/gpio_actor/__init__.py

+ 4
- 6
modules/base_plugins/gpio_actor/__init__.py 查看文件

@@ -53,14 +53,15 @@ class GPIOPWM(ActorBase):
if self.frequency is None: if self.frequency is None:
self.frequency = 0.5 # 2 sec self.frequency = 0.5 # 2 sec


self.p = GPIO.PWM(int(self.gpio), float(self.frequency))
if self.p is None:
self.p = GPIO.PWM(int(self.gpio), float(self.frequency))
self.p.start(int(self.power)) self.p.start(int(self.power))


def set_power(self, power): def set_power(self, power):
''' '''
Optional: Set the power of your actor Optional: Set the power of your actor
:param power: int value between 0 - 100 :param power: int value between 0 - 100
:return:
:return:
''' '''
if power is not None: if power is not None:
self.power = int(power) self.power = int(power)
@@ -96,12 +97,9 @@ class Dummy(ActorBase):
''' '''
Code to switch on the actor Code to switch on the actor
:param power: int value between 0 - 100 :param power: int value between 0 - 100
:return:
:return:
''' '''
print "ON" print "ON"


def off(self): def off(self):
print "OFF" print "OFF"




正在加载...
取消
保存