usb hid 라이브러리
[링크 : https://circuitpython.org/libraries]
circuit python uf2 다운로드
[링크 : https://circuitpython.org/board/raspberry_pi_pico/]
step 1. circuit python uf2 파일 쓰기
BOOTSEL 누르고 부팅해서 adafruit-circuitpython-raspberry_pi_pico-en_US-6.3.0.uf2 파일을 드라이브에 던진다.
step 2. lib 복사
circuitpython이 설치되면 리부팅 되고 아래와 같은 구조의 디렉토리가 보이게 된다.
adafruit-circuitpython-bundle-6.x-mpy-20210625.zip 를 받아 zip 파일내의
adafruit_hid 디렉토리를 lib/adafruit_hid 에 복사한다.
[링크 : https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries]
step 3. code.py 작성
아래는 꽂으면 A만 미친듯이 눌러대는 녀석이다. (그러니 현재는 테러용 USB ㅋㅋ)
마치 shift가 눌린 것 처럼 작동하는데 코드는 좀 더 분석이 필요하다.
Import time import board import digitalio import usb_hid from adafruit_hid.keyboard import Keyboard from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS from adafruit_hid.keycode import Keycode # The Keycode sent for each button, will be paired with a control key keys_pressed = [Keycode.A, "Hello World!\n"] control_key = Keycode.SHIFT # The keyboard object! time.sleep(1) # Sleep for a bit to avoid a race condition on some systems keyboard = Keyboard(usb_hid.devices) keyboard_layout = KeyboardLayoutUS(keyboard) # We're in the US :) while True: keyboard_layout.write('A') time.sleep(0.01) |
Hello world 출력하는 키보드(!) 예제 ㅋㅋ
import time import board import digitalio import usb_hid from adafruit_hid.keyboard import Keyboard from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS from adafruit_hid.keycode import Keycode # The keyboard object! time.sleep(1) # Sleep for a bit to avoid a race condition on some systems keyboard = Keyboard(usb_hid.devices) keyboard_layout = KeyboardLayoutUS(keyboard) # We're in the US :) while True: keyboard_layout.write('H') keyboard_layout.write('e') keyboard_layout.write('l') keyboard_layout.write('l') keyboard_layout.write('o') keyboard_layout.write(' ') keyboard_layout.write('w') keyboard_layout.write('o') keyboard_layout.write('r') keyboard_layout.write('l') keyboard_layout.write('d') time.sleep(1) |
[링크 : https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython]
[링크 : https://learn.adafruit.com/circuitpython-essentials/circuitpython-hid-keyboard-and-mouse]
'embeded > raspberry pi' 카테고리의 다른 글
AArch64 linux cpu features (0) | 2021.06.30 |
---|---|
citcuitpyrhon joystick (0) | 2021.06.28 |
rpi pico pinout (0) | 2021.06.28 |
rpi 3b+ with bt / uart (0) | 2021.06.28 |
rpi pico USB OTG를 이용한 오실로스코프 (0) | 2021.06.27 |