当前位置: 首页>>代码示例>>Python>>正文


Python PiStorms.waitForKeyPress方法代码示例

本文整理汇总了Python中PiStorms.PiStorms.waitForKeyPress方法的典型用法代码示例。如果您正苦于以下问题:Python PiStorms.waitForKeyPress方法的具体用法?Python PiStorms.waitForKeyPress怎么用?Python PiStorms.waitForKeyPress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PiStorms.PiStorms的用法示例。


在下文中一共展示了PiStorms.waitForKeyPress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: measurements

# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import waitForKeyPress [as 别名]
    while psm.getKeyPressCount() < 1:
        accel = imu.get_accelall()[0]
        if accel == ('','',''):
            answer = psm.screen.askQuestion(["AbsoluteIMU not found!", "Please connect an AbsoluteIMU sensor", "to BAS1."], ["OK", "Cancel"], goBtn=True)
            if answer != 0: break
        # append the data, but only if x, y, and z are all reasonable measurements (not something crazy like over 30,000)
        if all(accel[i] < 30000 for i in range(3)):
            datax = np.append(datax, accel[0])
            datay = np.append(datay, accel[1])
            dataz = np.append(dataz, accel[2])
        time.sleep(0.01) # take a short break to let the Pi do the other things it needs to (like draw the screen)
    stop = True

threading.Thread(target=captureData).start() # create a new thread that will run this method and start it

image = tempfile.NamedTemporaryFile()
while not stop:
    plt.plot(datax, color="red")
    plt.plot(datay, color="green")
    plt.plot(dataz, color="blue")
    plt.tight_layout()
    plt.savefig(image.name, format="png")
    if psm.screen.getMode() != psm.screen.PS_MODE_POPUP: # as long as there's not a popup about the sensor missing...
        psm.screen.fillBmp(0,0, 320,240, image.name) # draw the image

plt.savefig("/home/pi/Documents/impact.png")
np.savetxt("/home/pi/Documents/impact.csv", np.column_stack([datax,datay,dataz]), delimiter=",", fmt="%i")

psm.screen.drawAutoText("Press GO to exit.", 2, 219, psm.screen.PS_BLACK)
psm.waitForKeyPress()
开发者ID:mindsensors,项目名称:PiStorms,代码行数:32,代码来源:03-Impact.py


注:本文中的PiStorms.PiStorms.waitForKeyPress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。