readd audio
This commit is contained in:
@@ -2,6 +2,7 @@ import time
|
|||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
import govee
|
import govee
|
||||||
|
import pygame
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
|
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
|
||||||
@@ -51,6 +52,13 @@ logo_cache = {}
|
|||||||
# --- Govee API ---
|
# --- Govee API ---
|
||||||
govee_api = govee.GoveeApi(key="")
|
govee_api = govee.GoveeApi(key="")
|
||||||
|
|
||||||
|
# --- PyGame Audio ---
|
||||||
|
pygame.mixer.init()
|
||||||
|
|
||||||
|
def play_goal_horn():
|
||||||
|
pygame.mixer.music.load("/usr/local/share/horn.mp3")
|
||||||
|
pygame.mixer.music.play()
|
||||||
|
|
||||||
def render_goal_frame(text, text_scale, bg_color, text_color):
|
def render_goal_frame(text, text_scale, bg_color, text_color):
|
||||||
big_h = max(8, int(32 * text_scale))
|
big_h = max(8, int(32 * text_scale))
|
||||||
big_img = Image.new("RGB", (1024, 128), bg_color)
|
big_img = Image.new("RGB", (1024, 128), bg_color)
|
||||||
@@ -289,6 +297,7 @@ def run():
|
|||||||
last_switch = time.time()
|
last_switch = time.time()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
play_goal_horn()
|
||||||
govee_api.set_diy_scene(GOVEE_SKU, GOVEE_DEVICE)
|
govee_api.set_diy_scene(GOVEE_SKU, GOVEE_DEVICE)
|
||||||
play_goal_celebration()
|
play_goal_celebration()
|
||||||
govee_api.set_to_original_color(GOVEE_SKU, GOVEE_DEVICE)
|
govee_api.set_to_original_color(GOVEE_SKU, GOVEE_DEVICE)
|
||||||
|
|||||||
Reference in New Issue
Block a user