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 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 )