mirror of
https://github.com/Manuel83/craftbeerpi3
synced 2026-08-10 02:55:27 +02:00
GPIOPWM: Fixed misleading label "duty cycle" to "frequency", and handle decimal frequency values. Tested working with Rpi.GPIO
This commit is contained in:
@@ -36,10 +36,10 @@ class GPIOSimple(ActorBase):
|
|||||||
class GPIOPWM(ActorBase):
|
class GPIOPWM(ActorBase):
|
||||||
|
|
||||||
gpio = Property.Select("GPIO", options=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27], description="GPIO to which the actor is connected")
|
gpio = Property.Select("GPIO", options=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27], description="GPIO to which the actor is connected")
|
||||||
duty_cylce = Property.Number("Duty Cycle", configurable=True)
|
frequency = Property.Number("Frequency (Hz)", configurable=True)
|
||||||
|
|
||||||
p = None
|
p = None
|
||||||
power = 100
|
power = 100 # duty cycle
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
GPIO.setup(int(self.gpio), GPIO.OUT)
|
GPIO.setup(int(self.gpio), GPIO.OUT)
|
||||||
@@ -50,10 +50,10 @@ class GPIOPWM(ActorBase):
|
|||||||
if power is not None:
|
if power is not None:
|
||||||
self.power = int(power)
|
self.power = int(power)
|
||||||
|
|
||||||
if self.duty_cylce is None:
|
if self.frequency is None:
|
||||||
duty_cylce = 50
|
self.frequency = 0.5 # 2 sec
|
||||||
|
|
||||||
self.p = GPIO.PWM(int(self.gpio), int(self.duty_cylce))
|
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):
|
||||||
|
|||||||
Reference in New Issue
Block a user