display

λͺ¨λ“  λ””μŠ€ν”Œλ ˆμ΄ μ œμ–΄ λͺ…령을 μ°¨λ‘€λŒ€λ‘œ μ‹€ν–‰

from time import sleep

from e_drone.drone import *
from e_drone.protocol import *


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    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()

λ¬΄μž‘μœ„ μœ„μΉ˜μ™€ 크기의 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()

    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, 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()

    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, 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()
    
    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, 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(True, False, False, True, True)
    drone.open()

    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))

        drone.sendDisplayDrawCircle(x, y, radius, pixel, flagFill)
        sleep(0.05)

    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()

    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, 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()

    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, 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()

    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, 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()

    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)

        dataArray = drone.transfer(header, data)
        print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))

        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()

    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)

        dataArray = drone.transfer(header, data)
        print("{0} / {1}".format(i, convertByteArrayToString(dataArray)))

        sleep(0.03)

    drone.close()

Last updated