本文整理汇总了Python中PiStorms.PiStorms.getKeyPressCount方法的典型用法代码示例。如果您正苦于以下问题:Python PiStorms.getKeyPressCount方法的具体用法?Python PiStorms.getKeyPressCount怎么用?Python PiStorms.getKeyPressCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PiStorms.PiStorms
的用法示例。
在下文中一共展示了PiStorms.getKeyPressCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import getKeyPressCount [as 别名]
# This program introduces the process of continually updating a graph.
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")
import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile
plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('Voltage (V)')
plt.title('Battery Voltage')
plt.grid(True)
data = np.empty(0) # start with a completely empty data array
image = tempfile.NamedTemporaryFile() # we will be overwriting this same file
while psm.getKeyPressCount() < 1:
data = np.append(data, psm.battVoltage()) # add a data point with the current battery voltage
plt.plot(data, color="blue") # plot the data on the graph
plt.tight_layout() # make sure the entire plot fits on screen
plt.savefig(image.name, format="png") # save it
psm.screen.fillBmp(0,0, 320,240, image.name) # show it on screen
示例2: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import getKeyPressCount [as 别名]
# Date Author Comments
# July 2015 Henry Initial Authoring from SensorShield import SensorShield
import os,sys,inspect,time
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintAt(2, "PiStorms ")
psm.screen.termPrintAt(3, "GO button test:")
exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintAt(8, "Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):
pass
psm.screen.termPrintAt(5, "GO Button is = " +str(psm.isKeyPressed()))
psm.screen.termPrintAt(6, "Press Count = " +str(psm.getKeyPressCount()))
if (psm.screen.checkButton(0,0,320,320)):
psm.screen.termPrintln(" ")
psm.screen.termPrintln("Exiting .....")
exit = True
示例3:
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import getKeyPressCount [as 别名]
if(version < 2.05):
m = ["LED-sample", "This feature is not implemented on",
"PiStorms Firmware: V2.04 and earlier.",
"Please upgrade your PiStorms.",
" ",
"Click OK to exit."]
psm.screen.askQuestion(m,["OK"])
exit = True
else:
exit = False
psm.screen.termPrintAt(8, "Press Go button to exit")
d1 = 0.2
d2 = 0.2
oldKeyPressCount = psm.getKeyPressCount()
while(not exit):
psm.led(2,0,255,0)
time.sleep(d1)
psm.led(1,0,255,0)
time.sleep(d2)
psm.led(2,255,0,0)
time.sleep(d1)
psm.led(1,255,0,0)
time.sleep(d2)
psm.led(2,0,0,255)
time.sleep(d1)
psm.led(1,0,0,255)
time.sleep(d2)