buzzer

sendBuzzer 함수 테스트

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
if __name__ == '__main__':
8
9
drone = Drone()
10
drone.open()
11
12
13
drone.sendBuzzer(BuzzerMode.Mute, BuzzerScale.Mute.value, 500)
14
sleep(1)
15
16
drone.sendBuzzer(BuzzerMode.Scale, BuzzerScale.C4.value, 500)
17
sleep(1)
18
19
drone.sendBuzzer(BuzzerMode.Hz, 500, 500)
20
sleep(1)
21
22
23
drone.sendBuzzerMute(100)
24
drone.sendBuzzerMuteReserve(100)
25
sleep(1.2)
26
27
28
drone.sendBuzzerScale(BuzzerScale.C5, 500)
29
drone.sendBuzzerScaleReserve(BuzzerScale.D5, 500)
30
sleep(1.2)
31
32
33
drone.sendBuzzerHz(1000, 500)
34
drone.sendBuzzerHzReserve(1200, 500)
35
sleep(1.2)
36
37
38
drone.close()
Copied!

'학교 종이 땡땡땡' 일부 연주

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
if __name__ == '__main__':
8
9
drone = Drone()
10
drone.open()
11
12
drone.sendBuzzer(BuzzerMode.Mute, BuzzerScale.Mute.value, 100)
13
sleep(0.2);
14
15
drone.sendBuzzerScale(BuzzerScale.G4, 300); sleep(0.4);
16
drone.sendBuzzerScale(BuzzerScale.G4, 300); sleep(0.4);
17
drone.sendBuzzerScale(BuzzerScale.A4, 300); sleep(0.4);
18
drone.sendBuzzerScale(BuzzerScale.A4, 300); sleep(0.4);
19
drone.sendBuzzerScale(BuzzerScale.G4, 300); sleep(0.4);
20
drone.sendBuzzerScale(BuzzerScale.G4, 300); sleep(0.4);
21
drone.sendBuzzerScale(BuzzerScale.E4, 300); sleep(0.4);
22
23
drone.close()
Copied!

Buzzer 클래스 데이터를 직접 채워서 전송하기

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
if __name__ == '__main__':
8
9
drone = Drone()
10
drone.open()
11
12
13
header = Header()
14
15
header.dataType = DataType.Buzzer
16
header.length = Buzzer.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
21
data = Buzzer()
22
23
data.mode = BuzzerMode.Scale
24
data.value = BuzzerScale.C5.value
25
data.time = 500
26
27
drone.transfer(header, data)
28
sleep(1)
29
30
31
data.mode = BuzzerMode.Hz
32
data.value = 1200
33
data.time = 500
34
35
drone.transfer(header, data)
36
sleep(1)
37
38
39
drone.close()
Copied!
Last modified 1yr ago