mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
update dependencies and integrate inverted gpiopwm actor
This commit is contained in:
parent
8f7828b812
commit
beae95f847
4 changed files with 26 additions and 10 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.3.2"
|
__version__ = "4.3.3.a1"
|
||||||
__codename__ = "Winter Storm"
|
__codename__ = "Winter Storm"
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,9 @@ class GPIOActor(CBPiActor):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@parameters([Property.Select(label="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]), Property.Number(label="Frequency", configurable=True)])
|
@parameters([Property.Select(label="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]),
|
||||||
|
Property.Number(label="Frequency", configurable=True),
|
||||||
|
Property.Select(label="Inverted",options=["Yes","No"],description="Inverts PWM load if set to yes (e.g. 90% = 10%). Default: No")])
|
||||||
class GPIOPWMActor(CBPiActor):
|
class GPIOPWMActor(CBPiActor):
|
||||||
|
|
||||||
# Custom property which can be configured by the user
|
# Custom property which can be configured by the user
|
||||||
|
@ -113,10 +115,14 @@ class GPIOPWMActor(CBPiActor):
|
||||||
|
|
||||||
async def on_start(self):
|
async def on_start(self):
|
||||||
self.gpio = self.props.get("GPIO", None)
|
self.gpio = self.props.get("GPIO", None)
|
||||||
|
self.inverted = self.props.get("Inverted", "No")
|
||||||
self.frequency = self.props.get("Frequency", 0.5)
|
self.frequency = self.props.get("Frequency", 0.5)
|
||||||
if self.gpio is not None:
|
if self.gpio is not None:
|
||||||
GPIO.setup(self.gpio, GPIO.OUT)
|
GPIO.setup(self.gpio, GPIO.OUT)
|
||||||
GPIO.output(self.gpio, 0)
|
if self.inverted == "No":
|
||||||
|
GPIO.output(self.gpio, 0)
|
||||||
|
else:
|
||||||
|
GPIO.output(self.gpio, 1)
|
||||||
self.state = False
|
self.state = False
|
||||||
self.power = None
|
self.power = None
|
||||||
self.p = None
|
self.p = None
|
||||||
|
@ -135,7 +141,10 @@ class GPIOPWMActor(CBPiActor):
|
||||||
try:
|
try:
|
||||||
if self.p is None:
|
if self.p is None:
|
||||||
self.p = GPIO.PWM(int(self.gpio), float(self.frequency))
|
self.p = GPIO.PWM(int(self.gpio), float(self.frequency))
|
||||||
self.p.start(self.power)
|
if self.inverted == "No":
|
||||||
|
self.p.start(self.power)
|
||||||
|
else:
|
||||||
|
self.p.start(100- self.power)
|
||||||
self.state = True
|
self.state = True
|
||||||
# await self.cbpi.actor.actor_update(self.id,self.power)
|
# await self.cbpi.actor.actor_update(self.id,self.power)
|
||||||
except:
|
except:
|
||||||
|
@ -143,12 +152,19 @@ class GPIOPWMActor(CBPiActor):
|
||||||
|
|
||||||
async def off(self):
|
async def off(self):
|
||||||
logger.info("PWM ACTOR %s OFF - GPIO %s " % (self.id, self.gpio))
|
logger.info("PWM ACTOR %s OFF - GPIO %s " % (self.id, self.gpio))
|
||||||
self.p.ChangeDutyCycle(0)
|
if self.inverted == "No":
|
||||||
|
self.p.ChangeDutyCycle(0)
|
||||||
|
else:
|
||||||
|
self.p.ChangeDutyCycle(100)
|
||||||
|
|
||||||
self.state = False
|
self.state = False
|
||||||
|
|
||||||
async def set_power(self, power):
|
async def set_power(self, power):
|
||||||
if self.p and self.state == True:
|
if self.p and self.state == True:
|
||||||
self.p.ChangeDutyCycle(power)
|
if self.inverted == "No":
|
||||||
|
self.p.ChangeDutyCycle(power)
|
||||||
|
else:
|
||||||
|
self.p.ChangeDutyCycle(100 - power) # Set power to 100-value to invert output
|
||||||
await self.cbpi.actor.actor_update(self.id,power)
|
await self.cbpi.actor.actor_update(self.id,power)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ aiohttp-swagger==1.0.16
|
||||||
async-timeout==4.0.3
|
async-timeout==4.0.3
|
||||||
aiojobs==1.2.1
|
aiojobs==1.2.1
|
||||||
aiosqlite==0.17.0
|
aiosqlite==0.17.0
|
||||||
cryptography==41.0.7
|
cryptography==42.0.4
|
||||||
pyopenssl==23.3.0
|
pyopenssl==24.0.0
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
voluptuous==0.13.1
|
voluptuous==0.13.1
|
||||||
pyfiglet==1.0.2
|
pyfiglet==1.0.2
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -48,8 +48,8 @@ setup(name='cbpi4',
|
||||||
"async-timeout==4.0.3",
|
"async-timeout==4.0.3",
|
||||||
"aiojobs==1.2.1 ",
|
"aiojobs==1.2.1 ",
|
||||||
"aiosqlite==0.17.0",
|
"aiosqlite==0.17.0",
|
||||||
"cryptography==41.0.7",
|
"cryptography==42.0.4",
|
||||||
"pyopenssl==23.3.0",
|
"pyopenssl==24.0.0",
|
||||||
"requests==2.31.0",
|
"requests==2.31.0",
|
||||||
"voluptuous==0.13.1",
|
"voluptuous==0.13.1",
|
||||||
"pyfiglet==1.0.2",
|
"pyfiglet==1.0.2",
|
||||||
|
|
Loading…
Reference in a new issue