hyperpixel2r python
Version 0.0.1
터치 IC 용 I2C 버스를 사용하는 HyperPixel 2R 드라이버를 설치해야합니다 -https://github.com/pimoroni/hyperpixel2r
/boot/config.txt 편집하고 추가 : hyperpixel2r 이후에 :disable-touch 하십시오.
dtoverlay=hyperpixel2r:disable-touch
이렇게하면 Linux 터치 드라이버가 비활성화되어 Python이 터치 IC와 대화 할 수 있습니다.
PYPI의 안정적인 라이브러리 :
pip3 install hyperpixel2r 경우에 따라 sudo 사용하거나 PIP를 설치해야 할 수도 있습니다. sudo apt install python3-pip
Github의 최신/개발 라이브러리 :
git clone https://github.com/pimoroni/hyperpixel2r-pythoncd hyperpixel2r-pythonsudo ./install.sh Raspberry Pi OS와 함께 배송 된 Pygame 버전은 480x480과 같은 비표준 해상도를 좋아하지 않습니다. HDMI 핫 플러그를 강제 한 다음 480x480 영역으로 HyperPixel 2.0 "Round에 표시하여 /boot/config.txt : in /boot/config.txt :
# Force 640x480 video for Pygame / HyperPixel2r
hdmi_force_hotplug=1
hdmi_mode=1
hdmi_group=1
터치 드라이버 인스턴스 설정 :
touch = Touch ( bus = 11 , i2c_addr = 0x15 , interrupt_pin = 27 ): @touch.on_touch 로 핸들러를 장식하여 터치를 읽어야합니다.
핸들러는 인수 touch_id , x , y 및 state 수락해야합니다.
touch_id -0 또는 1에 따라 추적되는 터치에 따라x -x는 0에서 479에서 좌표를합니다y -y는 0에서 479까지 좌표를합니다state -State State True , 릴리스에 대한 False예를 들어:
@ touch . on_touch
def handle_touch ( touch_id , x , y , state ):
print ( touch_id , x , y , state )