基于中断的树莓pi矩阵键盘库
pad4pi的Python项目详细描述
PAD4PI
一个基于中断的python 2/3库,用于使用raspberry pi gpio pins读取matrixkeypad按键。
pipinstallpad4pi
使用4x3 matrix keypad在覆盆子pi b+上进行测试,但它应该适用于4x4和其他尺寸。
用法
frompad4piimportrpi_gpioKEYPAD=[[1,2,3],[4,5,6],[7,8,9],["*",0,"#"]]ROW_PINS=[4,14,15,17]# BCM numberingCOL_PINS=[18,27,22]# BCM numberingfactory=rpi_gpio.KeypadFactory()# Try factory.create_4_by_3_keypad# and factory.create_4_by_4_keypad for reasonable defaultskeypad=factory.create_keypad(keypad=KEYPAD,row_pins=ROW_PINS,col_pins=COL_PINS)defprintKey(key):print(key)# printKey will be called each time a keypad button is pressedkeypad.registerKeyPressHandler(printKey)
当您的程序退出时,调用^ {TT1}$以确保RasBuriPi的GPIO引脚复位。
许可证
根据GNU Lesser General Public License Version 3(lgpl v3)授权。