73 lines
1.8 KiB
Python
73 lines
1.8 KiB
Python
import os
|
|
import utils.govee as govee
|
|
from enum import Enum
|
|
from pathlib import Path
|
|
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
|
|
from dotenv import load_dotenv
|
|
|
|
# modes
|
|
import modes.score_mode as score_mode
|
|
|
|
# --- Load environment vars ---
|
|
load_dotenv()
|
|
|
|
# --- Default vars ---
|
|
SCRIPT_DIR = Path(__file__).parent.resolve()
|
|
ASSET_DIR = os.path.join(SCRIPT_DIR, "assets")
|
|
LOGO_DIR = os.path.join(ASSET_DIR, "logos")
|
|
|
|
# --- importable data dict ---
|
|
data = {
|
|
"paths": {
|
|
"SCRIPT_DIR": SCRIPT_DIR,
|
|
"ASSET_DIR": ASSET_DIR,
|
|
"LOGO_DIR": LOGO_DIR
|
|
},
|
|
"fonts": {
|
|
"font": graphics.Font().LoadFont(os.path.join(ASSET_DIR, "fonts/7x13.bdf")),
|
|
"font_small": graphics.Font().LoadFont(os.path.join(ASSET_DIR, "fonts/5x7.bdf")),
|
|
"font_big": graphics.Font().LoadFont(os.path.join(ASSET_DIR, "fonts/9x18.bdf"))
|
|
}
|
|
}
|
|
|
|
# --- Matrix config ---
|
|
options = RGBMatrixOptions()
|
|
options.rows = 32
|
|
options.cols = 64
|
|
options.chain_length = 4
|
|
options.parallel = 1
|
|
options.hardware_mapping = "regular"
|
|
options.gpio_slowdown = 5
|
|
options.disable_hardware_pulsing = True
|
|
options.brightness = 80
|
|
|
|
matrix = RGBMatrix(options=options)
|
|
canvas = matrix.CreateFrameCanvas()
|
|
|
|
# --- Pre-built colors ---
|
|
class Colors(Enum):
|
|
WHITE = (255, 255, 255)
|
|
YELLOW = (255, 200, 0)
|
|
RED = (255, 50, 50)
|
|
SABRES_BLUE = (0, 135, 48)
|
|
SABRES_GOLD = (252, 20, 210)
|
|
|
|
# --- Govee API ---
|
|
if os.environ['GOVEE_API_KEY']:
|
|
govee_api = govee.GoveeApi(key=os.environ["GOVEE_API_KEY"])
|
|
|
|
# --- PyGame Audio ---
|
|
# pygame.mixer.init()
|
|
# def play_audio(filename):
|
|
# pygame.mixer.music.load(os.path.join(ASSET_DIR, filename))
|
|
# pygame.mixer.music.play()
|
|
|
|
# --- Main loop ---
|
|
def run():
|
|
global canvas
|
|
|
|
score_mode.run_board(canvas, matrix)
|
|
|
|
if __name__ == "__main__":
|
|
run()
|