Exemplo n.º 1
0
# https://github.com/adafruit/Adafruit_CircuitPython_HID

import usb_hid
from adafruit_hid.gamepad import Gamepad

gp = Gamepad(usb_hid.devices)

# Test on Linux with:
#   jstest-gtk
#   https://jstest-gtk.gitlab.io/

# click gamepad buttons
# button index is 1-based
# icons in jstest-gtk will flash briefly
# jstest-gtk maps to (0, 2, 3, 6)
gp.click_buttons(1, 3, 4, 7)

# move joysticks in range [-127, 127]
# jstest-gtk maps to [-32767, 32767]
gp.move_joysticks(x = 90, y = 70, z = -80, r_z = 60)
Exemplo n.º 2
0
        gp.move_joysticks(x=x, y=y, z=z, r_z=r_z)
    else:
        gp.move_joysticks(x=0, y=0, z=0, r_z=0)

reader = mfrc522.MFRC522(gpioRst=board.D0, gpioCs=board.D1, cardWaitCount=20)

print("\nPlace card before reader to read from address 0x08\n")

try:
    while True:
        for i, switch in enumerate(switches):
            if not switch.value:
                if not switchPressedValues[i]:
                    switchPressedValues[i] = True
                    print("button {} pressed".format(i + 1))
                    gp.click_buttons(i + 1)
            else:
                switchPressedValues[i] = False

        no_value_count += 1
        if no_value_count > 2:
            no_value_count = 0
            if last_value != "":
                last_value = ""
                send_value(last_value)
        
        (stat, tag_type) = reader.request(reader.REQIDL) 

        if stat == reader.OK:

            (stat, raw_uid) = reader.anticoll()