forked from nebhead/PiFire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grillplat_prototype.py
executable file
·72 lines (56 loc) · 1.82 KB
/
grillplat_prototype.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
# *****************************************
# PiFire Grill Platform Prototype Interface Library
# *****************************************
#
# Description: This library simulates controlling the Grill outputs via
# Raspberry Pi GPIOs, to a 4-channel relay
#
# *****************************************
class GrillPlatform:
def __init__(self, outpins, inpins, triggerlevel='LOW'):
self.outpins = outpins # { 'power' : 4, 'auger' : 14, 'fan' : 15, 'igniter' : 18 }
self.inpins = inpins # { 'selector' : 17 }
if triggerlevel == 'LOW':
# Defines for Active LOW relay
self.RELAY_ON = 0
self.RELAY_OFF = 1
else:
# Defines for Active HIGH relay
self.RELAY_ON = 1
self.RELAY_OFF = 0
self.outpins['auger'] = self.RELAY_OFF
self.outpins['fan'] = self.RELAY_OFF
self.outpins['igniter'] = self.RELAY_OFF
self.outpins['power'] = self.RELAY_ON
self.inpins['selector'] = self.RELAY_ON
def AugerOn(self):
self.outpins['auger'] = self.RELAY_ON
def AugerOff(self):
self.outpins['auger'] = self.RELAY_OFF
def FanOn(self):
self.outpins['fan'] = self.RELAY_ON
def FanOff(self):
self.outpins['fan'] = self.RELAY_OFF
def FanToggle(self):
if(self.outpins['fan'] == self.RELAY_ON):
self.outpins['fan'] = self.RELAY_OFF
else:
self.outpins['fan'] = self.RELAY_ON
def IgniterOn(self):
self.outpins['igniter'] = self.RELAY_ON
def IgniterOff(self):
self.outpins['igniter'] = self.RELAY_OFF
def PowerOn(self):
self.outpins['power'] = self.RELAY_ON
def PowerOff(self):
self.outpins['power'] = self.RELAY_OFF
def GetInputStatus(self):
return (self.inpins['selector'])
def SetInputStatus(self, value):
self.inpins['selector'] = value
def GetOutputStatus(self):
self.current = {}
for item in self.outpins:
self.current[item] = self.outpins[item]
return self.current