-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (47 loc) · 1.88 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import threading
from scraper import Scraper
import time
from display import DisplayDriver
from screens.playing import playing
from screens.black import black
from screens.messages import messages
from Messages_Manager import Messages_Manager
from departures import Departures
from line_manager import Line_Manager
from sonos_state import Sonos_State
from stations import s8
import flask_server
from luma.core.sprite_system import framerate_regulator
def main():
s8_city = Departures(s8.name, s8.into_city, s8.into_city_warning, s8.into_city_times)
s8_airport = Departures(s8.name, s8.to_airport, s8.to_airport_warning, s8.to_airport_times)
lines = Line_Manager([s8_city, s8_airport])
# Create black / idle screen
black_screen = black()
# Setup Sonos playing screen
#sonos_state = Sonos_State("http://192.168.178.21:5005", ["Beam", "Küche", "Esszimmer"])
sonos_state = Sonos_State("http://localhost:5005", ["Beam", "Küche", "Esszimmer"])
playing_screen = playing(sonos_state)
# Setup messages screen
msg_manager = Messages_Manager()
messages_screen = messages(msg_manager)
# Init display
display = DisplayDriver(startup_screen=True)
display.add_screen(playing_screen)
display.add_screen(black_screen)
display.add_screen(messages_screen)
# Get departure data
#poll_time = 30 #seconds
#scraper = Scraper(lines)
#threading.Thread(target=scraper.get_data).start()
# Local server for short messages
#threading.Thread(target=server.run, args=[msg, display_sleeping]).start()
threading.Thread(target=flask_server.start_server, args=[display.toggle_sleep_mode, msg_manager]).start()
curr_time = time.time()
regulator = framerate_regulator(fps=6)
while True:
with regulator:
#print("sleeping: " + str(display_sleeping))
display.new_main()
if __name__ == "__main__":
main()