e_drone for python / Examples / Display
Modified : 2018.7.6
모든 디스플레이 제어 명령을 차례대로 실행
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
delay = 0.5
drone.sendDisplayClearAll(DisplayPixel.Black)
sleep(delay)
drone.sendDisplayClear(59, 27, 10, 10, DisplayPixel.White)
sleep(delay)
drone.sendDisplayInvert(54, 22, 20, 20)
sleep(delay)
drone.sendDisplayDrawPoint(64, 32, DisplayPixel.White)
sleep(delay)
drone.sendDisplayDrawLine(10, 10, 118, 54, DisplayPixel.White, DisplayLine.Dotted)
sleep(delay)
drone.sendDisplayDrawRect(44, 12, 40, 40, DisplayPixel.White, False, DisplayLine.Dashed)
sleep(delay)
drone.sendDisplayDrawCircle(64, 32, 20, DisplayPixel.White, True)
sleep(delay)
drone.sendDisplayDrawString(10, 10, "HELLO", DisplayFont.LiberationMono5x8, DisplayPixel.White)
sleep(delay)
drone.sendDisplayDrawStringAlign(0, 128, 30, "E-DRONE", DisplayAlign.Center, DisplayFont.LiberationMono10x16, DisplayPixel.White)
sleep(delay)
drone.close()
- sendDisplayClearAll()
- sendDisplayClear()
- sendDisplayInvert()
- sendDisplayDrawPoint()
- sendDisplayDrawLine()
- sendDisplayDrawRect()
- sendDisplayDrawCircle()
- sendDisplayDrawString()
- sendDisplayDrawStringAlign()
무작위 위치와 크기의 Clear를 100회 전송 (sendDisplayClear 함수 사용)
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
for i in range(0, 100, 1):
width = int(random.randint(0, 127))
height = int(random.randint(0, 63))
x = int(random.randint(0, 127) - width / 2)
y = int(random.randint(0, 63) - height / 2)
pixel = DisplayPixel(int(random.randint(0, 1)))
dataArray = drone.sendDisplayClear(x, y, width, height, pixel)
print("{0} / {1}".format(i, Drone.convertByteArrayToString(dataArray)))
sleep(0.03)
drone.close()
무작위 위치와 크기의 Clear를 100회 전송 (클래스 데이터 채워서 전송)
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
header = Header()
header.dataType = DataType.DisplayClear
header.length = DisplayClear.getSize()
header.from_ = DeviceType.Tester
header.to_ = DeviceType.Controller
data = DisplayClear()
for i in range(0, 100, 1):
data.width = int(random.randint(0, 127))
data.height = int(random.randint(0, 63))
data.x = int(random.randint(0, 127) - data.width / 2)
data.y = int(random.randint(0, 63) - data.height / 2)
data.pixel = DisplayPixel(int(random.randint(0, 1)))
dataArray = drone.transfer(header, data)
print("{0} / {1}".format(i, Drone.convertByteArrayToString(dataArray)))
sleep(0.03)
drone.close()
무작위 위치와 길이의 선을 100번 그리기 (sendDisplayDrawLine 함수 사용)
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
drone.sendDisplayClearAll(DisplayPixel(int(random.randint(0, 1))))
sleep(0.1)
for i in range(0, 100, 1):
x1 = int(random.randint(0, 127))
y1 = int(random.randint(0, 63))
x2 = int(random.randint(0, 127))
y2 = int(random.randint(0, 63))
pixel = DisplayPixel(int(random.randint(0, 1)))
line = DisplayLine(int(random.randint(0, 2)))
dataArray = drone.sendDisplayDrawLine(x1, y1, x2, y2, pixel, line)
print("{0} / {1}".format(i, Drone.convertByteArrayToString(dataArray)))
sleep(0.02)
drone.close()
무작위 위치와 크기의 원을 100번 출력하기 (sendDisplayDrawCircle 함수 사용)
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
for i in range(0, 100, 1):
x = int(random.randint(0, 127))
y = int(random.randint(0, 63))
radius = int(random.randint(0, 63))
pixel = DisplayPixel(int(random.randint(0, 1)))
flagFill = bool(random.randint(0, 1))
dataArray = drone.sendDisplayDrawCircle(x, y, radius, pixel, flagFill)
print("{0} / {1}".format(i, Drone.convertByteArrayToString(dataArray)))
sleep(0.03)
drone.close()
무작위 위치와 크기의 원을 100번 출력하기 (클래스 데이터 채워서 전송)
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
header = Header()
header.dataType = DataType.DisplayDrawCircle
header.length = DisplayDrawCircle.getSize()
header.from_ = DeviceType.Tester
header.to_ = DeviceType.Controller
data = DisplayDrawCircle()
for i in range(0, 100, 1):
data.x = int(random.randint(0, 127))
data.y = int(random.randint(0, 63))
data.radius = int(random.randint(0, 63))
data.pixel = DisplayPixel(int(random.randint(0, 1)))
data.flagFill = bool(random.randint(0, 1))
dataArray = drone.transfer(header, data)
print("{0} / {1}".format(i, Drone.convertByteArrayToString(dataArray)))
sleep(0.03)
drone.close()
무작위 위치와 크기의 사각형을 100번 출력하기 (sendDisplayDrawRect 함수 사용)
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
for i in range(0, 100, 1):
width = int(random.randint(0, 127))
height = int(random.randint(0, 63))
x = int(random.randint(0, 127) - width / 2)
y = int(random.randint(0, 63) - height / 2)
pixel = DisplayPixel(int(random.randint(0, 1)))
flagFill = bool(random.randint(0, 1))
line = DisplayLine(int(random.randint(0, 2)))
dataArray = drone.sendDisplayDrawRect(x, y, width, height, pixel, flagFill, line)
print("{0} / {1}".format(i, Drone.convertByteArrayToString(dataArray)))
sleep(0.03)
drone.close()
무작위 위치와 크기의 사각형을 100번 출력하기 (클래스 데이터 채워서 전송)
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
header = Header()
header.dataType = DataType.DisplayDrawRect
header.length = DisplayDrawRect.getSize()
header.from_ = DeviceType.Tester
header.to_ = DeviceType.Controller
data = DisplayDrawRect()
for i in range(0, 100, 1):
data.width = int(random.randint(0, 127))
data.height = int(random.randint(0, 63))
data.x = int(random.randint(0, 127) - data.width / 2)
data.y = int(random.randint(0, 63) - data.height / 2)
data.pixel = DisplayPixel(int(random.randint(0, 1)))
data.flagFill = bool(random.randint(0, 1))
data.line = DisplayLine(int(random.randint(0, 2)))
dataArray = drone.transfer(header, data)
print("{0} / {1}".format(i, Drone.convertByteArrayToString(dataArray)))
sleep(0.03)
drone.close()
'HELLO' 문자열을 무작위 위치에 100번 출력하기
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
header = Header()
header.dataType = DataType.DisplayDrawString
header.length = DisplayDrawString.getSize()
header.from_ = DeviceType.Tester
header.to_ = DeviceType.Controller
data = DisplayDrawString()
for i in range(0, 100, 1):
data.x = int(random.randint(0, 127))
data.y = int(random.randint(0, 63))
data.font = DisplayFont(int(random.randint(0, 1)))
data.pixel = DisplayPixel(int(random.randint(0, 1)))
data.message = "HELLO"
header.length = DisplayDrawString.getSize() + len(data.message)
print("{0} / {1}".format(i, drone.transfer(header, data)))
sleep(0.03)
drone.close()
'LOVE' 문자열을 왼쪽, 중앙, 오른쪽 정렬을 사용하여 무작위 위치에 10번 출력하기
import random
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone()
drone.open("COM22")
header = Header()
header.dataType = DataType.DisplayDrawStringAlign
header.length = DisplayDrawStringAlign.getSize()
header.from_ = DeviceType.Tester
header.to_ = DeviceType.Controller
data = DisplayDrawStringAlign()
for i in range(0, 10, 1):
data.x_start = 0
data.x_end = 127
data.y = int(random.randint(0, 63))
data.align = DisplayAlign(int(random.randint(0, 2)))
data.font = DisplayFont(int(random.randint(0, 1)))
data.pixel = DisplayPixel(int(random.randint(0, 1)))
data.message = "LOVE"
header.length = DisplayDrawStringAlign.getSize() + len(data.message)
print("{0} / {1}".format(i, drone.transfer(header, data)))
sleep(0.03)
drone.close()
e_drone for python
- Intro
- System
- Protocol
- Drone
- Examples - Ping
- Examples - Information
- Examples - Pairing
- Examples - Control
- Examples - Sensor
- Examples - Motor
- Examples - Setup
- Examples - Buzzer
- Examples - Vibrator
- Examples - Light
- Examples - Display
- Examples - Input
- Examples - Error