-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup_pattern.py
60 lines (53 loc) · 2.29 KB
/
startup_pattern.py
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
import time
import os
import pygame
from led_utils import init_strip, clear_leds, LED_COUNT_A, LED_PIN_A, LED_CHANNEL_A, LED_COUNT_B, LED_PIN_B, LED_CHANNEL_B, load_led_mapping, get_leds_for_tile
from rpi_ws281x import *
def play_audio(file_path):
pygame.mixer.music.load(file_path)
pygame.mixer.music.play()
def diagonal_demo(strip_a, strip_b):
grid_tiles = [
['A1', 'A-1'],
['A2', 'A-2', 'B1', 'B-1'],
['A3', 'A-3', 'B2', 'B-2', 'C1', 'C-1'],
['A4', 'A-4', 'B3', 'B-3', 'C2', 'C-2', 'D1', 'D-1'],
['A5', 'A-5', 'B4', 'B-4', 'C3', 'C-3', 'D2', 'D-2', 'E1', 'E-1'],
['A6', 'A-6', 'B5', 'B-5', 'C4', 'C-4', 'D3', 'D-3', 'E2', 'E-2', 'F1', 'F-1'],
['B6', 'B-6', 'C5', 'C-5', 'D4', 'D-4', 'E3', 'E-3', 'F2', 'F-2', 'G1', 'G-1'],
['C6', 'C-6', 'D5', 'D-5', 'E4', 'E-4', 'F3', 'F-3', 'G2', 'G-2'],
['D6', 'D-6', 'E5', 'E-5', 'F4', 'F-4', 'G3', 'G-3'],
['E6', 'E-6', 'F5', 'F-5', 'G4', 'G-4'],
['F6', 'F-6', 'G5', 'G-5'],
['G6', 'G-6']
]
# Path to the audio file
audio_file = 'audio/breaker_trimmed.ogg'
intro_file = 'audio/uplink_established.ogg'
play_audio(intro_file)
time.sleep(2.410)
# Light up diagonally
for row in grid_tiles:
play_audio(audio_file) # Play audio for each row
for tile in row:
leds_a = get_leds_for_tile(tile, 'a')
leds_b = get_leds_for_tile(tile, 'b')
for led in leds_a:
strip_a.setPixelColor(led - 1, Color(255, 0, 0)) # Red color
for led in leds_b:
strip_b.setPixelColor(led - 1, Color(255, 0, 0)) # Red color
strip_a.show()
strip_b.show()
time.sleep(0.750) # Adjust the speed of the demo here
# Turn off diagonally
for row in grid_tiles:
for tile in row:
leds_a = get_leds_for_tile(tile, 'a')
leds_b = get_leds_for_tile(tile, 'b')
for led in leds_a:
strip_a.setPixelColor(led - 1, Color(0, 0, 0)) # Turn off
for led in leds_b:
strip_b.setPixelColor(led - 1, Color(0, 0, 0)) # Turn off
strip_a.show()
strip_b.show()
time.sleep(0.750) # Adjust the speed of the demo here