|
10 | 10 | """ |
11 | 11 |
|
12 | 12 | import time |
| 13 | +import random |
13 | 14 | import digitalio |
14 | 15 | import audioio |
15 | 16 | import busio |
|
19 | 20 |
|
20 | 21 | # CUSTOMISE COLORS HERE: |
21 | 22 | COLOR = (0, 120, 120) # Default idle is light blue |
22 | | -ALT_COLOR = (255, 255, 255) # hit color is bright white |
| 23 | +ALT_COLOR = (255, 50, 0) # hit color is orange |
23 | 24 |
|
24 | 25 | # CUSTOMISE IDLE PULSE SPEED HERE: 0 is fast, above 0 slows down |
25 | | -IDLE_PULSE_SPEED = 0.05 # Default is 0.1 seconds |
26 | | -SWING_BLAST_SPEED = 0.01 |
| 26 | +IDLE_PULSE_SPEED = 0 # Default is 0 seconds |
| 27 | +SWING_BLAST_SPEED = 0.007 |
27 | 28 |
|
28 | 29 | # CUSTOMISE BRIGHTNESS HERE: must be a number between 0 and 1 |
29 | | -IDLE_PULSE_BRIGHTNESS_MIN = 0.3 # Default minimum idle pulse brightness |
30 | | -IDLE_PULSE_BRIGHTNESS_MAX = 0.6 # Default maximum idle pulse brightness |
| 30 | +IDLE_PULSE_BRIGHTNESS_MIN = 0.2 # Default minimum idle pulse brightness |
| 31 | +IDLE_PULSE_BRIGHTNESS_MAX = 1 # Default maximum idle pulse brightness |
31 | 32 |
|
32 | 33 | # CUSTOMISE SENSITIVITY HERE: smaller numbers = more sensitive to motion |
33 | | -HIT_THRESHOLD = 500 |
34 | | -SWING_THRESHOLD = 125 |
| 34 | +HIT_THRESHOLD = 250 |
| 35 | +SWING_THRESHOLD = 150 |
35 | 36 |
|
36 | 37 | # Set to the length in seconds of the "on.wav" file |
37 | 38 | POWER_ON_SOUND_DURATION = 1.7 |
38 | 39 |
|
39 | | -NUM_PIXELS = 30 # Number of pixels used in project |
| 40 | +NUM_PIXELS = 83 # Number of pixels used in project |
40 | 41 | NEOPIXEL_PIN = board.D5 |
41 | 42 | POWER_PIN = board.D10 |
42 | 43 |
|
@@ -120,6 +121,22 @@ def mix(color_1, color_2, weight_2): |
120 | 121 | int(color_1[1] * weight_1 + color_2[1] * weight_2), |
121 | 122 | int(color_1[2] * weight_1 + color_2[2] * weight_2)) |
122 | 123 |
|
| 124 | +# List of swing wav files without the .wav in the name for use with play_wav() |
| 125 | +swing_sounds = [ |
| 126 | + 'swing1', |
| 127 | + 'swing2', |
| 128 | + 'swing3', |
| 129 | + 'swing4', |
| 130 | +] |
| 131 | + |
| 132 | +# List of hit wav files without the .wav in the name for use with play_wav() |
| 133 | +hit_sounds = [ |
| 134 | + 'hit1', |
| 135 | + 'hit2', |
| 136 | + 'hit3', |
| 137 | + 'hit4', |
| 138 | +] |
| 139 | + |
123 | 140 |
|
124 | 141 | mode = 0 # Initial mode = OFF |
125 | 142 |
|
@@ -150,12 +167,12 @@ def mix(color_1, color_2, weight_2): |
150 | 167 | # comparing thresholds...use squared values instead.) |
151 | 168 | if accel_total > HIT_THRESHOLD: # Large acceleration = HIT |
152 | 169 | TRIGGER_TIME = time.monotonic() # Save initial time of hit |
153 | | - play_wav('hit') # Start playing 'hit' sound |
| 170 | + play_wav(random.choice(hit_sounds)) # Start playing 'hit' sound |
154 | 171 | COLOR_ACTIVE = COLOR_HIT # Set color to fade from |
155 | 172 | mode = 3 # HIT mode |
156 | 173 | elif mode == 1 and accel_total > SWING_THRESHOLD: # Mild = SWING |
157 | 174 | TRIGGER_TIME = time.monotonic() # Save initial time of swing |
158 | | - play_wav('swing') # Start playing 'swing' sound |
| 175 | + play_wav(random.choice(swing_sounds)) # Randomly choose from available swing sounds |
159 | 176 | # make a larson scanner animation_time |
160 | 177 | strip_backup = strip[0:-1] |
161 | 178 | for p in range(-1, len(strip)): |
|
0 commit comments