mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
Change Inverted logic for GPIO Actor
If sensor is set to active, GPIO pin should be high under normal conditions. If inverted, GPIO pin should be low when sensor is active. This logic is aligned with the old craftbeerpi3 GPIOSystem plugin
This commit is contained in:
parent
9938ce6de1
commit
9caca9074a
1 changed files with 3 additions and 3 deletions
|
@ -20,17 +20,17 @@ except Exception:
|
|||
import RPi.GPIO as GPIO
|
||||
|
||||
|
||||
@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.Select(label="Inverted", options=["Yes", "No"])])
|
||||
@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.Select(label="Inverted", options=["Yes", "No"],description="No: Active on high; Yes: Active on low")])
|
||||
class GPIOActor(CBPiActor):
|
||||
|
||||
|
||||
def get_GPIO_state(self, state):
|
||||
# ON
|
||||
if state == 1:
|
||||
return 0 if self.inverted == False else 1
|
||||
return 1 if self.inverted == False else 0
|
||||
# OFF
|
||||
if state == 0:
|
||||
return 1 if self.inverted == False else 0
|
||||
return 0 if self.inverted == False else 1
|
||||
|
||||
async def start(self):
|
||||
await super().start()
|
||||
|
|
Loading…
Reference in a new issue