-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
87 lines (70 loc) · 2.62 KB
/
Copy pathmain.py
File metadata and controls
87 lines (70 loc) · 2.62 KB
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
#!/usr/bin/env python3
"""
DeskClock — fullscreen clock + weather for Raspberry Pi touchscreen.
Runs on framebuffer (SDL_VIDEODRIVER=fbcon) without X11/Wayland.
"""
import os
import sys
# ── SDL environment ────────────────────────────────────────────────────────────
# Use KMSDRM (DRM/KMS) — the modern Linux display backend; no X11/Wayland needed.
os.environ.setdefault("SDL_VIDEODRIVER", "kmsdrm")
# Disable audio (not needed, avoids ALSA errors)
os.environ["SDL_AUDIODRIVER"] = "dummy"
# Use evdev touch + mouse input
os.environ.setdefault("SDL_INPUT_LINUX_EVDEV", "1")
import pygame
from config_manager import ConfigManager
from weather_service import WeatherService
from wifi_service import WifiService
from news_service import NewsService
from hotspot_service import HotspotService
from spotify_service import SpotifyService
from clock_screen import ClockScreen
from settings_screen import SettingsScreen
SCREEN_W = 1024
SCREEN_H = 600
FPS = 15 # low FPS is fine for a clock — saves CPU
def main():
pygame.init()
pygame.mouse.set_visible(False)
try:
screen = pygame.display.set_mode(
(SCREEN_W, SCREEN_H),
pygame.FULLSCREEN | pygame.NOFRAME,
)
except Exception:
# Fallback windowed (for dev/testing on desktop)
screen = pygame.display.set_mode((SCREEN_W, SCREEN_H))
pygame.display.set_caption("DeskClock")
config = ConfigManager()
weather = WeatherService(config)
wifi = WifiService()
news = NewsService()
hotspot = HotspotService()
spotify = SpotifyService(config)
clock_screen = ClockScreen(screen, config, weather, news, spotify)
settings_screen = SettingsScreen(screen, config, wifi, weather, hotspot, spotify)
current = clock_screen
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
running = False
result = current.handle_event(event)
if result == "settings":
current = settings_screen
settings_screen.on_enter()
elif result == "clock":
current = clock_screen
clock_screen.on_enter()
current.update()
current.draw()
pygame.display.flip()
clock.tick(FPS)
pygame.quit()
sys.exit(0)
if __name__ == "__main__":
main()