diff --git a/Propmaker_Master_Sword/code.py b/Propmaker_Master_Sword/code.py index ba6e450de..e7c48188f 100644 --- a/Propmaker_Master_Sword/code.py +++ b/Propmaker_Master_Sword/code.py @@ -10,6 +10,7 @@ All text above must be included in any redistribution. """ import time +import random import digitalio import audioio import busio @@ -19,24 +20,24 @@ import adafruit_lis3dh # CUSTOMISE COLORS HERE: COLOR = (0, 120, 120) # Default idle is light blue -ALT_COLOR = (255, 255, 255) # hit color is bright white +ALT_COLOR = (255, 50, 0) # hit color is bright white # CUSTOMISE IDLE PULSE SPEED HERE: 0 is fast, above 0 slows down -IDLE_PULSE_SPEED = 0.05 # Default is 0.1 seconds -SWING_BLAST_SPEED = 0.01 +IDLE_PULSE_SPEED = 0 # Default is 0.1 seconds +SWING_BLAST_SPEED = 0.007 # CUSTOMISE BRIGHTNESS HERE: must be a number between 0 and 1 -IDLE_PULSE_BRIGHTNESS_MIN = 0.3 # Default minimum idle pulse brightness -IDLE_PULSE_BRIGHTNESS_MAX = 0.6 # Default maximum idle pulse brightness +IDLE_PULSE_BRIGHTNESS_MIN = 0.2 # Default minimum idle pulse brightness +IDLE_PULSE_BRIGHTNESS_MAX = 1 # Default maximum idle pulse brightness # CUSTOMISE SENSITIVITY HERE: smaller numbers = more sensitive to motion -HIT_THRESHOLD = 500 -SWING_THRESHOLD = 125 +HIT_THRESHOLD = 250 +SWING_THRESHOLD = 150 # Set to the length in seconds of the "on.wav" file POWER_ON_SOUND_DURATION = 1.7 -NUM_PIXELS = 30 # Number of pixels used in project +NUM_PIXELS = 83 # Number of pixels used in project NEOPIXEL_PIN = board.D5 POWER_PIN = board.D10 @@ -120,6 +121,22 @@ def mix(color_1, color_2, weight_2): int(color_1[1] * weight_1 + color_2[1] * weight_2), int(color_1[2] * weight_1 + color_2[2] * weight_2)) +# List of swing wav files without the .wav in the name for use with play_wav() +swing_sounds = [ + 'swing1', + 'swing2', + 'swing3', + 'swing4', +] + +# List of hit wav files without the .wav in the name for use with play_wav() +hit_sounds = [ + 'hit1', + 'hit2', + 'hit3', + 'hit4', +] + mode = 0 # Initial mode = OFF @@ -150,12 +167,12 @@ while True: # comparing thresholds...use squared values instead.) if accel_total > HIT_THRESHOLD: # Large acceleration = HIT TRIGGER_TIME = time.monotonic() # Save initial time of hit - play_wav('hit') # Start playing 'hit' sound + play_wav(random.choice(hit_sounds)) # Start playing 'hit' sound COLOR_ACTIVE = COLOR_HIT # Set color to fade from mode = 3 # HIT mode elif mode == 1 and accel_total > SWING_THRESHOLD: # Mild = SWING TRIGGER_TIME = time.monotonic() # Save initial time of swing - play_wav('swing') # Start playing 'swing' sound + play_wav(random.choice(swing_sounds)) # Randomly choose from available swing sounds # make a larson scanner animation_time strip_backup = strip[0:-1] for p in range(-1, len(strip)): diff --git a/Propmaker_Master_Sword/sounds/hit.wav b/Propmaker_Master_Sword/sounds/hit.wav deleted file mode 100644 index ddad9e78d..000000000 Binary files a/Propmaker_Master_Sword/sounds/hit.wav and /dev/null differ diff --git a/Propmaker_Master_Sword/sounds/hit1.wav b/Propmaker_Master_Sword/sounds/hit1.wav new file mode 100644 index 000000000..eb86f1add Binary files /dev/null and b/Propmaker_Master_Sword/sounds/hit1.wav differ diff --git a/Propmaker_Master_Sword/sounds/hit2.wav b/Propmaker_Master_Sword/sounds/hit2.wav new file mode 100644 index 000000000..0a295fc07 Binary files /dev/null and b/Propmaker_Master_Sword/sounds/hit2.wav differ diff --git a/Propmaker_Master_Sword/sounds/hit3.wav b/Propmaker_Master_Sword/sounds/hit3.wav new file mode 100644 index 000000000..446edad1a Binary files /dev/null and b/Propmaker_Master_Sword/sounds/hit3.wav differ diff --git a/Propmaker_Master_Sword/sounds/hit4.wav b/Propmaker_Master_Sword/sounds/hit4.wav new file mode 100644 index 000000000..ebb1ad5bd Binary files /dev/null and b/Propmaker_Master_Sword/sounds/hit4.wav differ diff --git a/Propmaker_Master_Sword/sounds/swing.wav b/Propmaker_Master_Sword/sounds/swing.wav deleted file mode 100644 index b2da30e72..000000000 Binary files a/Propmaker_Master_Sword/sounds/swing.wav and /dev/null differ diff --git a/Propmaker_Master_Sword/sounds/swing1.wav b/Propmaker_Master_Sword/sounds/swing1.wav new file mode 100644 index 000000000..8eb696f2c Binary files /dev/null and b/Propmaker_Master_Sword/sounds/swing1.wav differ diff --git a/Propmaker_Master_Sword/sounds/swing2.wav b/Propmaker_Master_Sword/sounds/swing2.wav new file mode 100644 index 000000000..09d5b4f03 Binary files /dev/null and b/Propmaker_Master_Sword/sounds/swing2.wav differ diff --git a/Propmaker_Master_Sword/sounds/swing3.wav b/Propmaker_Master_Sword/sounds/swing3.wav new file mode 100644 index 000000000..ac67e69a7 Binary files /dev/null and b/Propmaker_Master_Sword/sounds/swing3.wav differ diff --git a/Propmaker_Master_Sword/sounds/swing4.wav b/Propmaker_Master_Sword/sounds/swing4.wav new file mode 100644 index 000000000..ca71d8f81 Binary files /dev/null and b/Propmaker_Master_Sword/sounds/swing4.wav differ