-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathModuleController.py
78 lines (62 loc) · 1.91 KB
/
ModuleController.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
74
75
76
77
78
###################################################
# FILE: ModuleController.py #
# AUTHOR: NotPike #
# Function: Helper function for module selection. #
# PIN comes in, function is ran if it #
# matches something in select(). #
###################################################
import logging
import pathlib
### IMPORT MODULES ###
from modules.Audio import *
from modules.Time import *
from modules.Weather import *
from modules.Numbers import *
from modules.Parrot import *
class ModuleController:
def __init__(self, env):
self.env = env
### DECLARE MODULES ###
self.audio = Audio()
self.time = Time()
self.weather = Weather()
self.numbers = Numbers()
self.parrot = Parrot()
# Select function, PIN goes in, function is preformed
# and returns True if sucessfull so the PIN cal be cleared
# in main.py.
def select(self, pin):
# Test
if(pin == "123"):
logging.info("Test PIN")
return True
# May 4th be with you
elif(pin == "054"):
self.audio.run(str(pathlib.Path().absolute()) + "/wav/StarWars3.wav") #Audio File
return True
# DATE = 3283
elif(pin == "3283"):
self.time.readDate()
return True
# TIME = 8463
elif(pin == "8463"):
self.time.readTime()
return True
# WX = 99
elif(pin == "99"):
self.weather.run()
return True
# ###
elif(pin == "###"):
self.numbers.run()
return True
# ECHO =3246
elif(pin == "3246"):
self.parrot.run()
return True
# Clear pin with "*#"
elif("*#" in pin):
return True
# Invalid PIN
else:
return False