forked from nebhead/PiFire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrillplat_pifire.py
executable file
·73 lines (54 loc) · 1.88 KB
/
grillplat_pifire.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
73
#!/usr/bin/env python3
# *****************************************
# PiFire OEM Interface Library
# *****************************************
#
# Description: This library supports
# controlling the PiFire Outputs, alongside
# the OEM controller outputs via
# Raspberry Pi GPIOs, to a 4-channel relay
#
# *****************************************
# *****************************************
# Imported Libraries
# *****************************************
from gpiozero import OutputDevice
from gpiozero import Button
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 }
self.current = {}
self.selector = Button(self.inpins['selector'])
active_high = triggerlevel == 'HIGH'
self.fan = OutputDevice(self.outpins['fan'], active_high=active_high, initial_value=False)
self.auger = OutputDevice(self.outpins['auger'], active_high=active_high, initial_value=False)
self.igniter = OutputDevice(self.outpins['igniter'], active_high=active_high, initial_value=False)
self.power = OutputDevice(self.outpins['power'], active_high=active_high, initial_value=False)
def auger_on(self):
self.auger.on()
def auger_off(self):
self.auger.off()
def fan_on(self):
self.fan.on()
def fan_off(self):
self.fan.off()
def fan_toggle(self):
self.fan.toggle()
def igniter_on(self):
self.igniter.on()
def igniter_off(self):
self.igniter.off()
def power_on(self):
self.power.on()
def power_off(self):
self.power.off()
def get_input_status(self):
return self.selector.value
def get_output_status(self):
self.current = {}
self.current['auger'] = self.auger.is_active
self.current['igniter'] = self.igniter.is_active
self.current['power'] = self.power.is_active
self.current['fan'] = self.fan.is_active
return self.current