input

버튼 입력값 출력

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
def eventButton(button):
8
print("eventButton() / " +
9
"Button: 0b{0:16}, Event: {1:6}".format(bin(button.button)[2:].zfill(16), button.event.name))
10
11
12
if __name__ == '__main__':
13
14
drone = Drone()
15
drone.open()
16
17
# 이벤트 핸들링 함수 등록
18
drone.setEventHandler(DataType.Button, eventButton)
19
20
drone.sendPing(DeviceType.Controller)
21
22
for i in range(10, 0, -1):
23
print(i)
24
sleep(1)
25
26
drone.close()
Copied!

조이스틱 입력값 출력

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
def eventJoystick(joystick):
8
print("eventJoystick() / " +
9
"L: ({0:4}, {1:4}), {2:5}, {3:5} / ".format(joystick.left.x, joystick.left.y, joystick.left.direction.name, joystick.left.event.name) +
10
"R: ({0:4}, {1:4}), {2:5}, {3:5}".format(joystick.right.x, joystick.right.y, joystick.right.direction.name, joystick.right.event.name))
11
12
13
if __name__ == '__main__':
14
15
drone = Drone()
16
drone.open()
17
18
# 이벤트 핸들링 함수 등록
19
drone.setEventHandler(DataType.Joystick, eventJoystick)
20
21
drone.sendPing(DeviceType.Controller)
22
23
for i in range(10, 0, -1):
24
print(i)
25
sleep(1)
26
27
drone.close()
Copied!
Last modified 1yr ago