display

모든 디스플레이 제어 명령을 차례대로 실행

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
delay = 0.5
13
14
drone.sendDisplayClearAll(DisplayPixel.Black)
15
sleep(delay)
16
17
drone.sendDisplayClear(59, 27, 10, 10, DisplayPixel.White)
18
sleep(delay)
19
20
drone.sendDisplayInvert(54, 22, 20, 20)
21
sleep(delay)
22
23
drone.sendDisplayDrawPoint(64, 32, DisplayPixel.White)
24
sleep(delay)
25
26
drone.sendDisplayDrawLine(10, 10, 118, 54, DisplayPixel.White, DisplayLine.Dotted)
27
sleep(delay)
28
29
drone.sendDisplayDrawRect(44, 12, 40, 40, DisplayPixel.White, False, DisplayLine.Dashed)
30
sleep(delay)
31
32
drone.sendDisplayDrawCircle(64, 32, 20, DisplayPixel.White, True)
33
sleep(delay)
34
35
drone.sendDisplayDrawString(10, 10, "HELLO", DisplayFont.LiberationMono5x8, DisplayPixel.White)
36
sleep(delay)
37
38
drone.sendDisplayDrawStringAlign(0, 128, 30, "E-DRONE", DisplayAlign.Center, DisplayFont.LiberationMono10x16, DisplayPixel.White)
39
sleep(delay)
40
41
drone.close()
Copied!

무작위 위치와 크기의 Clear를 100회 전송 (sendDisplayClear 함수 사용)

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, 100, 1):
14
15
width = int(random.randint(0, 127))
16
height = int(random.randint(0, 63))
17
x = int(random.randint(0, 127) - width / 2)
18
y = int(random.randint(0, 63) - height / 2)
19
pixel = DisplayPixel(int(random.randint(0, 1)))
20
21
dataArray = drone.sendDisplayClear(x, y, width, height, pixel)
22
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
23
24
sleep(0.03)
25
26
drone.close()
Copied!

무작위 위치와 크기의 Clear를 100회 전송 (클래스 데이터 채워서 전송)

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.DisplayClear
16
header.length = DisplayClear.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
data = DisplayClear()
21
22
for i in range(0, 100, 1):
23
24
data.width = int(random.randint(0, 127))
25
data.height = int(random.randint(0, 63))
26
data.x = int(random.randint(0, 127) - data.width / 2)
27
data.y = int(random.randint(0, 63) - data.height / 2)
28
data.pixel = DisplayPixel(int(random.randint(0, 1)))
29
30
dataArray = drone.transfer(header, data)
31
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
32
33
sleep(0.03)
34
35
drone.close()
Copied!

무작위 위치와 길이의 선을 100번 그리기 (sendDisplayDrawLine 함수 사용)

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
drone.sendDisplayClearAll(DisplayPixel(int(random.randint(0, 1))))
14
sleep(0.1)
15
16
for i in range(0, 100, 1):
17
18
x1 = int(random.randint(0, 127))
19
y1 = int(random.randint(0, 63))
20
x2 = int(random.randint(0, 127))
21
y2 = int(random.randint(0, 63))
22
pixel = DisplayPixel(int(random.randint(0, 1)))
23
line = DisplayLine(int(random.randint(0, 2)))
24
25
dataArray = drone.sendDisplayDrawLine(x1, y1, x2, y2, pixel, line)
26
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
27
28
sleep(0.02)
29
30
drone.close()
Copied!

무작위 위치와 크기의 원을 100번 출력하기 (sendDisplayDrawCircle 함수 사용)

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, False, False, True, True)
11
drone.open()
12
13
for i in range(0, 100, 1):
14
15
x = int(random.randint(0, 127))
16
y = int(random.randint(0, 63))
17
radius = int(random.randint(0, 63))
18
pixel = DisplayPixel(int(random.randint(0, 1)))
19
flagFill = bool(random.randint(0, 1))
20
21
drone.sendDisplayDrawCircle(x, y, radius, pixel, flagFill)
22
sleep(0.05)
23
24
drone.close()
Copied!

무작위 위치와 크기의 원을 100번 출력하기 (클래스 데이터 채워서 전송)

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.DisplayDrawCircle
16
header.length = DisplayDrawCircle.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
data = DisplayDrawCircle()
21
22
for i in range(0, 100, 1):
23
24
data.x = int(random.randint(0, 127))
25
data.y = int(random.randint(0, 63))
26
data.radius = int(random.randint(0, 63))
27
data.pixel = DisplayPixel(int(random.randint(0, 1)))
28
data.flagFill = bool(random.randint(0, 1))
29
30
dataArray = drone.transfer(header, data)
31
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
32
33
sleep(0.03)
34
35
drone.close()
36
Copied!

무작위 위치와 크기의 사각형을 100번 출력하기 (sendDisplayDrawRect 함수 사용)

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, 100, 1):
14
15
width = int(random.randint(0, 127))
16
height = int(random.randint(0, 63))
17
x = int(random.randint(0, 127) - width / 2)
18
y = int(random.randint(0, 63) - height / 2)
19
pixel = DisplayPixel(int(random.randint(0, 1)))
20
flagFill = bool(random.randint(0, 1))
21
line = DisplayLine(int(random.randint(0, 2)))
22
23
dataArray = drone.sendDisplayDrawRect(x, y, width, height, pixel, flagFill, line)
24
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
25
26
sleep(0.03)
27
28
drone.close()
Copied!

무작위 위치와 크기의 사각형을 100번 출력하기 (클래스 데이터 채워서 전송)

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.DisplayDrawRect
16
header.length = DisplayDrawRect.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
data = DisplayDrawRect()
21
22
for i in range(0, 100, 1):
23
24
data.width = int(random.randint(0, 127))
25
data.height = int(random.randint(0, 63))
26
data.x = int(random.randint(0, 127) - data.width / 2)
27
data.y = int(random.randint(0, 63) - data.height / 2)
28
data.pixel = DisplayPixel(int(random.randint(0, 1)))
29
data.flagFill = bool(random.randint(0, 1))
30
data.line = DisplayLine(int(random.randint(0, 2)))
31
32
dataArray = drone.transfer(header, data)
33
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
34
35
sleep(0.03)
36
37
drone.close()
Copied!

'HELLO' 문자열을 무작위 위치에 100번 출력하기

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.DisplayDrawString
16
header.length = DisplayDrawString.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
data = DisplayDrawString()
21
22
for i in range(0, 100, 1):
23
24
data.x = int(random.randint(0, 127))
25
data.y = int(random.randint(0, 63))
26
data.font = DisplayFont(int(random.randint(0, 1)))
27
data.pixel = DisplayPixel(int(random.randint(0, 1)))
28
data.message = "HELLO"
29
30
header.length = DisplayDrawString.getSize() + len(data.message)
31
32
dataArray = drone.transfer(header, data)
33
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
34
35
sleep(0.03)
36
37
drone.close()
Copied!

'LOVE' 문자열을 왼쪽, 중앙, 오른쪽 정렬을 사용하여 무작위 위치에 10번 출력하기

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.DisplayDrawStringAlign
16
header.length = DisplayDrawStringAlign.getSize()
17
header.from_ = DeviceType.Tester
18
header.to_ = DeviceType.Controller
19
20
data = DisplayDrawStringAlign()
21
22
for i in range(0, 10, 1):
23
24
data.x_start = 0
25
data.x_end = 127
26
data.y = int(random.randint(0, 63))
27
data.align = DisplayAlign(int(random.randint(0, 2)))
28
data.font = DisplayFont(int(random.randint(0, 1)))
29
data.pixel = DisplayPixel(int(random.randint(0, 1)))
30
data.message = "LOVE"
31
32
header.length = DisplayDrawStringAlign.getSize() + len(data.message)
33
34
dataArray = drone.transfer(header, data)
35
print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))
36
37
sleep(0.03)
38
39
drone.close()
Copied!
Last modified 1yr ago