#!./bin/python3

import os
import yaml
import threading

# Include pygame without support prompt
# Typing only available from version >= 2.0

os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import pygame # type: ignore

from musikautomat import Musikautomat

# Configuration

config = yaml.safe_load(open("config.yml"))

fbdev = config.get("fbdev", "/dev/fb0")
dx = config.get("dimx", 128)
dy = config.get("dimy", 160)

# Initialise pygame

os.environ["SDL_FBDEV"] = fbdev
pygame.init()

# Create the display
print("Trying to open %s with %sx%s" % (fbdev, dx, dy))
pydsp = pygame.display.set_mode((dx, dy))
pygame.display.set_caption("Musikautomat")
pygame.mouse.set_visible(False)
pygame.key.set_repeat(400, 100)

ma = Musikautomat(pydsp, config)
ma.runDisplay()
