light

sendLightManual() 함수를 사용하여 조종기 LED 제어하기

1
import random
2
from time import sleep
3
4
from e_drone.drone import *
5
from e_drone.protocol import *
6
7
8
if __name__ == '__main__':
9
10
drone = Drone()
11
drone.open()
12
13
14
drone.sendLightManual(DeviceType.Controller, 0xFF, 0)
15
sleep(1);
16
17
18
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyRed.value, 10)
19
sleep(1);
20
21
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyRed.value, 100)
22
sleep(1);
23
24
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyRed.value, 0)
25
sleep(1);
26
27
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyGreen.value, 10)
28
sleep(1);
29
30
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyGreen.value, 100)
31
sleep(1);
32
33
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyGreen.value, 0)
34
sleep(1);
35
36
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyBlue.value, 10)
37
sleep(1);
38
39
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyBlue.value, 100)
40
sleep(1);
41
42
drone.sendLightManual(DeviceType.Controller, LightFlagsController.BodyBlue.value, 0)
43
sleep(1);
44
45
drone.sendLightManual(DeviceType.Controller, 0b00000011, 10)
46
sleep(1);
47
48
drone.sendLightManual(DeviceType.Controller, 0b00000011, 100)
49
sleep(1);
50
51
drone.sendLightManual(DeviceType.Controller, 0b00000011, 0)
52
sleep(1);
53
54
drone.sendLightManual(DeviceType.Controller, 0b00000110, 10)
55
sleep(1);
56
57
drone.sendLightManual(DeviceType.Controller, 0b00000110, 100)
58
sleep(1);
59
60
drone.sendLightManual(DeviceType.Controller, 0b00000110, 0)
61
sleep(1);
62
63
drone.sendLightManual(DeviceType.Controller, 0b00000101, 10)
64
sleep(1);
65
66
drone.sendLightManual(DeviceType.Controller, 0b00000101, 100)
67
sleep(1);
68
69
drone.sendLightManual(DeviceType.Controller, 0b00000101, 0)
70
sleep(1);
71
72
73
drone.close()
Copied!

sendLightManual() 함수를 사용하여 드론 LED 제어하기

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.sendLightManual(DeviceType.Drone, 0xFF, 0)
14
sleep(1);
15
16
17
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyRed.value, 10)
18
sleep(1);
19
20
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyRed.value, 100)
21
sleep(1);
22
23
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyRed.value, 0)
24
sleep(1);
25
26
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyGreen.value, 10)
27
sleep(1);
28
29
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyGreen.value, 100)
30
sleep(1);
31
32
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyGreen.value, 0)
33
sleep(1);
34
35
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyBlue.value, 10)
36
sleep(1);
37
38
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyBlue.value, 100)
39
sleep(1);
40
41
drone.sendLightManual(DeviceType.Drone, LightFlagsDrone.BodyBlue.value, 0)
42
sleep(1);
43
44
45
drone.sendLightManual(DeviceType.Drone, 0x06, 10)
46
sleep(1);
47
48
drone.sendLightManual(DeviceType.Drone, 0x06, 100)
49
sleep(1);
50
51
drone.sendLightManual(DeviceType.Drone, 0x06, 0)
52
sleep(1);
53
54
drone.sendLightManual(DeviceType.Drone, 0x0A, 10)
55
sleep(1);
56
57
drone.sendLightManual(DeviceType.Drone, 0x0A, 100)
58
sleep(1);
59
60
drone.sendLightManual(DeviceType.Drone, 0x0A, 0)
61
sleep(1);
62
63
drone.sendLightManual(DeviceType.Drone, 0x0C, 10)
64
sleep(1);
65
66
drone.sendLightManual(DeviceType.Drone, 0x0C, 100)
67
sleep(1);
68
69
drone.sendLightManual(DeviceType.Drone, 0x0C, 0)
70
sleep(1);
71
72
73
drone.close()
Copied!

sendLightMode, sendLightEvent 함수를 사용하여 조종기 LED 제어하기

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
print("BodyHold")
14
drone.sendLightModeColor(LightModeController.BodyHold, 200, 200, 200, 0)
15
sleep(2);
16
17
18
#sendLightModeColor
19
print("BodyDimming 1")
20
drone.sendLightModeColor(LightModeController.BodyDimming, 3, 200, 0, 200)
21
sleep(3);
22
23
#sendLightModeColors
24
print("BodyDimming 2")
25
drone.sendLightModeColors(LightModeController.BodyDimming, 3, Colors.Cyan)
26
sleep(3);
27
28
29
# sendLightEventColor*
30
print("BodyDimming 3")
31
drone.sendLightEventColor(LightModeController.BodyDimming, 3, 3, 200, 200, 200)
32
sleep(3);
33
34
# sendLightEventColors*
35
print("BodyDimming 4")
36
drone.sendLightEventColors(LightModeController.BodyDimming, 3, 3, Colors.Magenta)
37
sleep(3);
38
39
40
drone.close()
Copied!

sendLightMode, sendLightEvent 함수를 사용하여 드론 LED 제어하기

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.sendLightModeColor(LightModeDrone.BodyHold, 200, 0, 200, 200)
14
sleep(1);
15
16
17
# sendLightModeColor*
18
drone.sendLightModeColor(LightModeDrone.BodyDimming, 3, 0, 0, 200)
19
sleep(3);
20
21
# sendLightModeColors*
22
drone.sendLightModeColors(LightModeDrone.BodyDimming, 3, Colors.Cyan)
23
sleep(3);
24
25
26
# sendLightEventColor*
27
drone.sendLightEventColor(LightModeDrone.BodyDimming, 3, 5, 200, 200, 200)
28
sleep(3);
29
30
# sendLightEventColors*
31
drone.sendLightEventColors(LightModeDrone.BodyDimming, 3, 3, Colors.Magenta)
32
sleep(3);
33
34
35
drone.close()
Copied!

조종기의 LED를 랜덤한 색으로 점점 밝아졌다 어두워지게 하는 명령을 10회 실행

    LightModeColor / sendLightModeColor 함수 사용
1
import random
2
from time import sleep
3
4
from e_drone.drone import *
5
from e_drone.protocol import *
6
7
8
if __name__ == '__main__':
9
10
drone = Drone()
11
drone.open()
12
13
for i in range(0, 10, 1):
14
15
r = int(random.randint(0, 255))
16
g = int(random.randint(0, 255))
17
b = int(random.randint(0, 255))
18
19
dataArray = drone.sendLightModeColor(LightModeController.BodyDimming, 1, r, g, b)
20
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
21
22
sleep(0.6)
23
24
drone.close()
Copied!

조종기의 LED를 랜덤한 색으로 점점 밝아졌다 어두워지게 하는 명령을 10회 실행

    LightModeColor / 클래스 데이터를 채워서 전송
1
import random
2
from time import sleep
3
4
from e_drone.drone import *
5
from e_drone.protocol import *
6
7
8
if __name__ == '__main__':
9
10
drone = Drone()
11
drone.open()
12
13
header = Header()
14
15
header.dataType = DataType.LightMode
16
header.length = LightModeColor.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
data = LightModeColor()
21
22
data.mode.mode = LightModeController.BodyDimming.value
23
data.mode.interval = 1
24
25
for i in range(0, 10, 1):
26
27
data.color.r = int(random.randint(0, 255))
28
data.color.g = int(random.randint(0, 255))
29
data.color.b = int(random.randint(0, 255))
30
31
dataArray = drone.transfer(header, data)
32
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
33
34
sleep(0.6)
35
36
drone.close()
Copied!

조종기의 LED를 랜덤한 색으로 점점 밝아졌다 어두워지게 하는 명령을 10회 실행

    LightModeColors / sendLightModeColors 함수 사용
1
import random
2
from time import sleep
3
4
from e_drone.drone import *
5
from e_drone.protocol import *
6
7
8
if __name__ == '__main__':
9
10
drone = Drone()
11
drone.open()
12
13
for i in range(0, 10, 1):
14
15
colors = Colors(random.randint(0, Colors.EndOfType.value))
16
17
dataArray = drone.sendLightModeColors(LightModeController.BodyDimming, 1, colors)
18
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
19
20
sleep(0.6)
21
22
drone.close()
Copied!

조종기의 LED를 랜덤한 색으로 점점 밝아졌다 어두워지게 하는 명령을 10회 실행

    LightModeColors / 클래스 데이터를 채워서 전송
1
import random
2
from time import sleep
3
4
from e_drone.drone import *
5
from e_drone.protocol import *
6
7
8
if __name__ == '__main__':
9
10
drone = Drone()
11
drone.open()
12
13
header = Header()
14
15
header.dataType = DataType.LightMode
16
header.length = LightModeColors.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
data = LightModeColors()
21
22
data.mode.mode = LightModeController.BodyDimming.value
23
data.mode.interval = 1
24
25
for i in range(0, 10, 1):
26
27
data.colors = Colors(random.randint(0, Colors.EndOfType.value))
28
29
dataArray = drone.transfer(header, data)
30
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
31
32
sleep(0.6)
33
34
drone.close()
Copied!

드론의 LED를 랜덤한 색으로 점점 밝아졌다 어두워지게 하는 명령을 10회 실행

    LightModeColors / sendLightDefaultColor 함수 사용
1
import random
2
from time import sleep
3
4
from e_drone.drone import *
5
from e_drone.protocol import *
6
7
8
if __name__ == '__main__':
9
10
drone = Drone(True, True, True, True, True)
11
drone.open()
12
13
for i in range(0, 10, 1):
14
15
r = int(random.randint(0, 255))
16
g = int(random.randint(0, 255))
17
b = int(random.randint(0, 255))
18
19
dataArray = drone.sendLightDefaultColor(LightModeDrone.BodyDimming, 1, r, g, b)
20
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
21
22
sleep(2)
23
24
drone.close()
Copied!
Last modified 1yr ago