-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (35 loc) · 904 Bytes
/
main.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
import json
import time
import vlc
import gui
f = open('data/data.json')
data = json.load(f)
f.close()
short_enabled = False
index = 0
def play_on_time(data):
time_string = time.strftime("%H:%M", time.localtime())
if time_string in data:
global index
index = data.index(time_string) + 1
play_n_clocks(3)
def play_n_clocks(n):
for _ in range(n):
p = vlc.MediaPlayer("data/clock.mp3")
p.play()
time.sleep(1)
duration = p.get_length() / 1000
time.sleep(duration - 1)
while True:
gui.main()
# TODO: LCD DISPLAY IMPLEMENTATION
if short_enabled:
play_on_time(data["short_hours"])
print(index)
print(data["short_hours"][index])
time.sleep(60)
else:
play_on_time(data["normal_hours"])
print(index)
print(data["normal_hours"][index])
time.sleep(60)