CoDrone DIY
  • ⚪소개하기
    • 펌웨어 업데이트 방법
      • Raspberry pi
      • Linux
      • Mac
      • Windows
      • Windows(.NET)
    • 다운로드용 자료 모음
  • 코드론 파이썬 라이브러리
    • 🔶파이썬
      • drone class
      • ping
      • information
      • pairing
      • control
      • sensor
      • buzzer
      • vibrator
      • light
      • display
      • input
      • error
    • 🔷프로토콜
      • Typedef
      • DataType
      • Definitions
      • Structs
      • Structs light
      • Structs display
      • Structs card
  • Friend Site
    • 🤍Buy CoDrone DIY
    • 💙ROBOLINK
Powered by GitBook
On this page
  • 버튼 입력값 출력
  • 조이스틱 입력값 출력
  1. 코드론 파이썬 라이브러리
  2. 파이썬

input

버튼 입력값 출력

from time import sleep

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


def eventButton(button):
    print("eventButton() / " +
        "Button: 0b{0:16}, Event: {1:6}".format(bin(button.button)[2:].zfill(16), button.event.name))


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Button, eventButton)

    drone.sendPing(DeviceType.Controller)

    for i in range(10, 0, -1):
        print(i)
        sleep(1)

    drone.close()

조이스틱 입력값 출력

from time import sleep

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


def eventJoystick(joystick):
    print("eventJoystick() / " +
        "L: ({0:4}, {1:4}), {2:5}, {3:5} / ".format(joystick.left.x, joystick.left.y, joystick.left.direction.name, joystick.left.event.name) +
        "R: ({0:4}, {1:4}), {2:5}, {3:5}".format(joystick.right.x, joystick.right.y, joystick.right.direction.name, joystick.right.event.name))


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Joystick, eventJoystick)

    drone.sendPing(DeviceType.Controller)

    for i in range(10, 0, -1):
        print(i)
        sleep(1)

    drone.close()
PreviousdisplayNexterror

Last updated 2 years ago

🔶