|
@@ -1,36 +1,56 @@
|
|
#!./bin/python3
|
|
#!./bin/python3
|
|
|
|
|
|
-import sys,os
|
|
|
|
|
|
+import sys, os, time
|
|
import yaml
|
|
import yaml
|
|
|
|
|
|
|
|
+# Include pygame without support prompt
|
|
|
|
+# Typing only available from version >= 2.0
|
|
|
|
+
|
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
-import pygame
|
|
|
|
-from pygame.locals import *
|
|
|
|
|
|
+import pygame # type: ignore
|
|
|
|
|
|
-# Configuration
|
|
|
|
-config = yaml.safe_load(open("config.yml"))
|
|
|
|
|
|
+from display import Display
|
|
|
|
|
|
-cfg_fbdev = config.get("fbdev", "/dev/fb1")
|
|
|
|
|
|
+# Configuration
|
|
|
|
|
|
-def out(o: str):
|
|
|
|
- print("-->", o)
|
|
|
|
|
|
+config = yaml.safe_load(open("config.yml"))
|
|
|
|
|
|
-out("Hello %s" % cfg_fbdev)
|
|
|
|
|
|
+fbdev = config.get("fbdev", "/dev/fb1")
|
|
|
|
+dx = config.get("dimx", 128)
|
|
|
|
+dy = config.get("dimy", 160)
|
|
|
|
|
|
# Initialise pygame
|
|
# Initialise pygame
|
|
|
|
|
|
|
|
+os.environ["SDL_FBDEV"] = fbdev
|
|
pygame.init()
|
|
pygame.init()
|
|
|
|
|
|
# Create the display
|
|
# Create the display
|
|
|
|
|
|
-dsp = pygame.display.set_mode((128, 160), 0, 32)
|
|
|
|
-pygame.display.set_caption('Musikautomat')
|
|
|
|
|
|
+pydsp = pygame.display.set_mode((dx, dy), 0, 32)
|
|
|
|
+pygame.display.set_caption("Musikautomat")
|
|
|
|
+pygame.mouse.set_visible(False)
|
|
|
|
+
|
|
|
|
+# Initialise state objects
|
|
|
|
+
|
|
|
|
+display = Display(config, pydsp)
|
|
|
|
+display.update()
|
|
|
|
+clk = pygame.time.Clock()
|
|
|
|
|
|
# Run the game loop
|
|
# Run the game loop
|
|
|
|
|
|
while True:
|
|
while True:
|
|
|
|
+ clk.tick(10) # We only need 10 FPS
|
|
|
|
+
|
|
for event in pygame.event.get():
|
|
for event in pygame.event.get():
|
|
- if event.type == QUIT:
|
|
|
|
|
|
+ if event.type == pygame.QUIT:
|
|
pygame.quit()
|
|
pygame.quit()
|
|
sys.exit()
|
|
sys.exit()
|
|
|
|
+ if event.type == pygame.KEYDOWN:
|
|
|
|
+ if event.key == pygame.K_LEFT:
|
|
|
|
+ print("1")
|
|
|
|
+ if event.key == pygame.K_RIGHT:
|
|
|
|
+ print("2")
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
pygame.display.update()
|
|
pygame.display.update()
|