示例#1
0
from time import sleep
from djitellopy import tello
import keyboard as kp

kp.init()
me = tello.Tello()
me.connect()
print(me.get_battery())


def getKeyboardInput():
    lr, fb, ud, yaw = 0, 0, 0, 0
    speed = 50

    if kp.getKey("LEFT"): lr = -speed
    elif kp.getKey("RIGHT"): lr = speed

    if kp.getKey("UP"): fb = speed
    elif kp.getKey("DOWN"): fb = -speed

    if kp.getKey("w"): ud = speed
    elif kp.getKey("s"): ud = -speed

    if kp.getKey("a"): yaw = -speed
    elif kp.getKey("d"): yaw = +speed

    if kp.getKey("q"): me.land()
    if kp.getKey("e"): me.takeoff()

    return [lr, fb, ud, yaw]
示例#2
0
def init():
    peripherals.init()
    keyboard.init()
示例#3
0
文件: main.py 项目: pyzzz/zzpysdl
        while core.pollEvent():
            evtype = core.event.type
            if evtype == SDL_QUIT:
                core.log("SDL_QUIT event")
                share.running = False
            elif evtype == SDL_KEYDOWN:
                #str(core.sdl.String)
                keyboard.keydown(str(SDL_GetKeyName(
                    core.event.key.keysym.sym)))
            elif evtype == SDL_KEYUP:
                keyboard.keyup(str(SDL_GetKeyName(core.event.key.keysym.sym)))


if __name__ == "__main__":
    try:
        #switch work dir to script dir
        os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
        #core.screenVideoMode = sdl.SDL_SWSURFACE
        #core.screenVideoMode |= sdl.SDL_FULLSCREEN
        core.init(
            define.windowWidth,
            define.windowHeight,
            define.windowBpp,
            define.windowTitle,
        )
        init.init()
        keyboard.init()
        mainLoop()
    except:
        core.logtraceerr()
    core.exitapp()
示例#4
0
import API
from API import title
from vk_api.bot_longpoll import VkBotEventType
from vk_api.longpoll import VkEventType
import keyboard as kbd
import Owl_database as odb
from config import token

odb.init()
poll = API.init()
kbd.init()

for event in poll.listen():

    if event.from_user and VkEventType.MESSAGE_NEW and event.obj[
            'text'] == token:
        res = odb.send_owls_to_chats()
        for s_chat in res.keys():
            API.send(s_chat, res[s_chat].description_new(), odb.kbd_send_owl(),
                     'photo-200716665_457239047')

    if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat:
        txt, chat, user = API.get_message_params(event)

        if txt.lower() in title(['start', 'старт', 'начать']):
            msg, key = odb.start()
            API.send(chat, msg, keyboard=key)

        elif txt.lower() in title(['отправляй совушек']):
            ans = odb.add_chat_to_send(chat)
            API.send(chat, ans)