Skip to content

Commit d05a577

Browse files
committed
update dice
1 parent 2ae9725 commit d05a577

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

software/audio/dice/dice.wav

29.3 KB
Binary file not shown.

software/dice.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def playwave(filename):
3030
audiopwr_on()
3131
i2s = audiobusio.I2SOut(AUDIO_BCK,AUDIO_WS,AUDIO_DATA)
3232
try :
33-
wave_file = open('audio/cn_girl/{}'.format(filename), "rb")
33+
wave_file = open(filename, "rb")
3434
wave = audiocore.WaveFile(wave_file)
3535
i2s.play(wave)
3636
while i2s.playing:
@@ -46,6 +46,7 @@ def playwave(filename):
4646
audiopwr_off()
4747
pass
4848

49+
4950
class Dice:
5051
def __init__(self):
5152
self.value=0
@@ -93,12 +94,13 @@ def stop(self):
9394

9495

9596

96-
TICK_DICE = 3.0
97+
TICK_DICE = 1.0
9798
#
9899
async def draw(dice):
99100
starttick=0.0
100101
while True:
101102
if dice.f_start==True:
103+
playwave("audio/dice/dice.wav")
102104
starttick = time.monotonic()
103105
dice.f_start=False
104106
dice.f_loop=True
@@ -109,7 +111,7 @@ async def draw(dice):
109111
tile_grid.x = display.width//2-50 +random.randint(-10,10)
110112
tile_grid.y = display.height//2-50+random.randint(-10,10)
111113
if time.monotonic()-starttick >= TICK_DICE:
112-
playwave("{}.wav".format(voice[dice.value]))
114+
playwave("audio/cn_girl/{}.wav".format(voice[dice.value]))
113115
dice.f_loop=False
114116
dice.f_stop=True
115117

0 commit comments

Comments
 (0)