-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
66 lines (56 loc) · 1.33 KB
/
example.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
61
62
63
64
65
66
from dfplayermini import Player
from machine import Pin
from time import sleep, sleep_ms
music = Player(pin_TX=Pin(4), pin_RX=Pin(5))
pp = Pin(12, Pin.IN, Pin.PULL_UP)
skip = Pin(13, Pin.IN, Pin.PULL_UP)
v_up = Pin(14, Pin.IN, Pin.PULL_UP)
v_down = Pin(15, Pin.IN, Pin.PULL_UP)
#print("set volume")
#music.volume(20)
#print("start play")
#music.play(1)
#sleep(2)
#print("stop play with fadeout")
#music.fadeout(2000)
#music.play('next')
#sleep(10)
#music.pause()
#sleep(3)
#music.loop()
#music.play(2)
#sleep(20)
pp_prev = True
skip_prev = True
v_up_prev = True
v_down_prev = True
playing = False
volume = 20
music.play(1)
print(playing)
while True:
if not pp.value() and pp.value() != pp_prev:
print("play/pause")
playing = ~playing
if playing:
music.pause()
else:
music.resume()
while not pp.value():
pp_prev = False
pp_prev = True
if not skip.value() and skip.value() != skip_prev:
print("skip")
while not skip.value():
skip_prev = False
skip_prev = True
if not v_up.value():
print("volume up")
volume = volume + 1
music.volume(volume)
sleep_ms(150)
if not v_down.value():
print("volume down")
volume = volume - 1
music.volume(volume)
sleep_ms(150)