/
gui.py
159 lines (121 loc) · 4.06 KB
/
gui.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import helper
import kivy
import os
import pyowm
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.config import Config
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
from kivy.lang import Builder
from kivy.clock import Clock
kivy.require("1.9.1")
Config.set('graphics', 'fullscreen', '1')
os.environ['DISPLAY'] = ":0"
class HomeScreen(Screen):
pass
class AlarmScreen(Screen):
pass
class LightScreen(Screen):
pass
class MediaScreen(Screen):
pass
class OptionScreen(Screen):
pass
class ScreenManagement(ScreenManager):
pass
class TriggerScreen(Screen):
pass
class PartyScreen(Screen):
pass
class WeatherLabel(Label):
def __init__(self, **kwargs):
# kivy stuff
super(WeatherLabel, self).__init__(**kwargs)
Clock.schedule_interval(self.update, 60)
def update(self, *args):
comms = helper.get_comms()
self.text = "Can you see me, Zack?"
owm = pyowm.OWM('d6b217578eb1e012d805e7490fac6560')
observation = owm.weather_at_place("Cleveland")
w = observation.get_weather()
comms.logger.info("Weather results: " + w)
temperature = w.get_temperature('fahrenheit')
tomorrow = pyowm.timeutils.tomorrow()
wind = w.get_wind()
self.text = str(w)
class Profile1(Label):
def __init__(self, **kwargs):
# kivy stuff
super(Profile1, self).__init__(**kwargs)
class Profile2(Label):
def __init__(self, **kwargs):
# kivy stuff
super(Profile2, self).__init__(**kwargs)
class LightLabel(Label):
def __init__(self, **kwargs):
# kivy stuff
super(LightLabel, self).__init__(**kwargs)
Clock.schedule_interval(self.update, 5)
def update(self, *args):
comms = helper.get_comms()
## DISPLAY DETECTED USERS HERE
self.text = "Hello Light Label!"
answer = comms.check_bluetooth('08:ec:a9:0f:88:3e')
self.text = self.text + str(answer)
class SystemInfo(Label):
def __init__(self, **kwargs):
# kivy stuff
super(SystemInfo, self).__init__(**kwargs)
class StatusBox(BoxLayout):
def __init__(self, **kwargs):
# kivy stuff
super(StatusBox, self).__init__(**kwargs)
# make the button update
Clock.schedule_interval(self.update, .1)
self.id = 'status'
self.alarm = helper.get_alarm()
self.p1 = Profile1()
self.p2 = Profile2()
self.sys = SystemInfo()
self.add_widget(self.p1)
self.add_widget(self.sys)
self.add_widget(self.p2)
def update(self, *args):
self.p1.text = self.alarm.fetch(0)
self.p2.text = self.alarm.fetch(1)
self.sys.text = self.alarm.now()
for profile in self.alarm.profiles:
if profile.running:
# if the alarm is running, change screen
App.get_running_app().root.current = 'trigger'
comms = helper.get_comms()
comms.play_fx(helper.DING2)
class MyButton(Button):
def __init__(self, **kwargs):
# kivy stuff
super(MyButton, self).__init__(**kwargs)
self.alarm = helper.get_alarm()
self.active_profile = "PROFILE 1"
def ding1(self):
helper.comms.play_fx(helper.DING1)
def ding2(self):
helper.comms.play_fx(helper.DING2)
def adjust_alarm(self, btn, change):
self.alarm.adjust_alarm(btn.text, change)
class MyProfileButton(MyButton):
def __init__(self, **kwargs):
# kivy stuff
super(MyProfileButton, self).__init__(**kwargs)
self.active_profile = "PROFILE 1"
def switch_profile(self):
if self.active_profile == "PROFILE 2":
self.active_profile = "PROFILE 1"
else:
self.active_profile = "PROFILE 2"
self.text = self.active_profile