本文整理汇总了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()