读取手柄状态-主动查询
MyJoy.getState()
返回值
使用示例:每隔一秒打印当前手柄数据
import time
from pi_driver import MyJoy
mjoy = MyJoy()
while True:
print(mjoy.getState())
time.sleep(1)
读取手柄状态-事件回调
MyJoy.callback
属性说明
使用示例:手柄有操作时,自动打印当前手柄数据
import time
from pi_driver import MyJoy
mjoy = MyJoy()
def cb():
print(mjoy.getState())
mjoy.callback=cb
while True:
time.sleep(1)