hyperpixel2r python
Version 0.0.1
您必須安裝Hyperpixel 2R驅動程序,該驅動器啟用I2C總線以進行觸摸IC -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 sudo apt install python3-pip
GitHub的最新/開發庫:
git clone https://github.com/pimoroni/hyperpixel2r-pythoncd hyperpixel2r-pythonsudo ./install.sh使用Raspberry Pi OS發貨的Pygame版本不喜歡480x480等非標準分辨率。您可以通過強制HDMI熱銷來偽造640x480標準顯示,然後僅在Hyperpixel 2.0“round。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到479y -y協調從0到479state - 觸摸的狀態True , False fors發布例如:
@ touch . on_touch
def handle_touch ( touch_id , x , y , state ):
print ( touch_id , x , y , state )