-
Notifications
You must be signed in to change notification settings - Fork 0
/
radioconsole.py
73 lines (59 loc) · 1.96 KB
/
radioconsole.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
import signal
signal.signal(signal.SIGHUP, lambda s, f: None)
# pylint: disable=wrong-import-position
import sys
import pygame
import pygame.freetype
from config_reader import cfg
import crash_handler
import AppManager
import apps
import pygame_ft5406
import splash_screen
ts = pygame_ft5406.ft5406Events()
pygame.display.init()
ts.start()
pygame.freetype.init()
pygame.font.init()
screen = pygame.display.set_mode(cfg.display.size)
splash = splash_screen.splash_screen(screen)
splash.draw_splash()
def safe_exit():
pygame.quit()
ts.stop()
sys.exit()
crash_handler.register(screen, safe_exit)
try:
sw = AppManager.appSwitcher(screen)
am = AppManager.appManager(sw)
splash.update_status("register apps")
am.register_app('rtl_fft', apps.WaterfallDisplay)
am.register_app('gpsd', apps.gps_status)
am.register_app('lte_status', apps.lte_status)
am.register_app('log_viewer', apps.LogViewer)
am.register_app('raspi_status', apps.RaspiStatus)
am.register_app('systemd_status', apps.SystemDStatus)
am.register_app('systemd_log_viewer', apps.SystemDLogViewer)
am.register_app('gpio_shutdown_status', apps.GPIOShutdown)
am.register_app('ardop_status', apps.ARDOPStatus)
am.register_app('direwolf_status', apps.DirewolfStatus)
splash.update_status("instantiating apps")
if len(sys.argv) > 1:
am.instantiate_apps(splash.update_status, only=sys.argv[1])
sw.switchFrontmostApp(sys.argv[1])
else:
am.instantiate_apps(splash.update_status)
sw.switchFrontmostApp('switcher')
clock = pygame.time.Clock()
while True:
time_delta = clock.tick(cfg.display.target_fps)/1000.0
for e in pygame.event.get():
if e.type is pygame.QUIT:
safe_exit()
sw.process_events(e)
sw.update(time_delta)
if sw.draw(screen):
pygame.display.update()
# pylint: disable=broad-except
except Exception as e:
crash_handler.crash(e)