本文整理汇总了Python中PiStorms.PiStorms.isKeyPressed方法的典型用法代码示例。如果您正苦于以下问题:Python PiStorms.isKeyPressed方法的具体用法?Python PiStorms.isKeyPressed怎么用?Python PiStorms.isKeyPressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PiStorms.PiStorms
的用法示例。
在下文中一共展示了PiStorms.isKeyPressed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sleep
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
print 'f.set()'
sleep(0.1)
psm.led(1, 0, 0, 0)
if __name__ == "__main__":
entered_house = Event()
found_bomb = Event()
got_victim = Event()
f_thread = Thread(target=follow, args=(entered_house, found_bomb, got_victim))
f_thread.start()
s_thread = Thread(target=search, args=(entered_house, found_bomb, got_victim))
s_thread.start()
while not exit:
sleep(0.05)
if psm.isKeyPressed(): # if the GO button is pressed
psm.screen.clearScreen()
psm.screen.termPrintln("Exiting to menu")
psm.led(1,0,0,0)
psm.BAM1.float()
psm.BAM2.float()
psm.BBM1.float()
psm.BBM2.float()
sleep(0.1)
exit = True
示例2: int
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
for (x, y, w, h) in faces:
# for displaying on exported display
cv2.circle(image, (x+w/2, y+h/2), int((w+h)/3), (255, 255, 255), 1)
# for showing on PiStorms screen
psm.screen.fillCircle((x+w)-w/2, y+h-h/2, int((w+h)/3), fill = (255,255,255),display = False)
psm.screen.fillCircle((x+w)-w/2, y+h-h/2, int(-2+(w+h)/3), fill = (0,0,0),display = False)
psm.screen.fillCircle((x+w)-w/2+w/4, y+h-h/4-h/2, 4, fill = (255,255,255),display = False)
psm.screen.fillCircle((x+w)-w/2-w/4, y+h-h/4-h/2, 4, fill = (255,255,255),display = True)
# show the frame use this if you are setup for Display export on your pc or VNC
#you may use Xming server for this
#cv2.imshow("Frame", image)
key = cv2.waitKey(1) & 0xFF
lastfaces = faces
# clear the stream in preparation for the next frame
rawCapture.truncate(0)
# if the `q` key was pressed, break from the loop
if((psm.isKeyPressed() == True) and psm.screen.isTouched()):
break
#if key == ord("q"):
# break
示例3: switchboard_register
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
if resp and resp.status_code == 200:
registered = True
except:
pass
if registered:
psm.screen.termPrintln('registered successfully')
else:
psm.screen.termPrintln('failed to register')
switchboard_register()
print 'starting event loop'
event_loop = bot.EventLoop(processors=(
#locator,
FrontBumperProcessor(driver),
remote,
path_follower,
))
while True:
if psm.isKeyPressed():
break
event_loop.step()
time.sleep(0.001)
driver.float()
psm.screen.termPrintln("Exiting ...")
示例4: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
psm = PiStorms() # PiStorms object
exit = False # break loop
while (not exit):
light = psm.BBS1.lightSensorNXT(True)
# 520
error = 540 - light #if within 40 on edge, if negative on line, if positive in white
# psm.BBM1.setSpeedSync(30)
# if (abs(error) < 20): #on edge
# psm.BBM1.setSpeedSync(30)
# psm.led(1,0,255,0) #green
if (error < 0): #on line, turn to right, left wheel accelerate
psm.BBM1.setSpeed(25)
psm.BBM2.setSpeed(-50)
psm.led(1,0,0,255)#blue
elif (error > 0): #on white, turn to left, right wheel accelerate
psm.BBM2.setSpeed(25)
psm.BBM1.setSpeed(-50)
psm.led(1,255,0,0)#Red
sleep(0.1)
if (psm.isKeyPressed()): #exit
psm.BBM1.brakeSync()
psm.led(1,0,0,0)
psm.screen.clearScreen()
psm.screen.termPrintln("")
psm.screen.termPrintln("Exiting to menu")
sleep(0.5)
exit = True
示例5: str
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
if ( ambientMode == True):
colorValue = psm.BAS1.ambientLightSensorEV3()
msg = "Color Seen: " + str(colorValue) + " (ambient)"
else:
colorValue = psm.BAS1.colorSensorEV3()
msg = "Color Seen: " + str(colorValue) + " (reflected)"
# print value only if it was changed.
if (old_colorValue != colorValue):
psm.screen.clearScreen()
psm.screen.drawAutoText(msg, 15, 164, fill=(255, 255, 255), size = 18)
psm.screen.drawAutoText("Touch screen to change mode", 15, 182, fill=(255, 255, 255), size = 18)
psm.screen.drawAutoText("between ambient/reflected", 15, 200, fill=(255, 255, 255), size = 18)
psm.screen.drawAutoText("Press Go to stop program", 15, 218, fill=(255, 255, 255), size = 18)
if(psm.isKeyPressed() == True): # if the GO button is pressed
psm.screen.clearScreen()
psm.screen.termPrintln("")
psm.screen.termPrintln("Exiting to menu")
doExit = True
#
# check if screen touched.
#
if(psm.screen.checkButton(0,0,320,320)):
# if scren was touched,
# reset BAS1 touch count
if ( ambientMode == False):
ambientMode = True
else:
ambientMode = False
示例6: elif
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
value = IR.readChannelProximity(1)
mode = "Proximity"
elif (count == 2):
psm.screen.termPrintAt(1, "Keep remote on channel 1 and ")
psm.screen.termPrintAt(2, "press joystick(s).")
value = IR.readRemote(1)
#Output is in array (L, R), where L is the left stick and R is the right stick
#1 is up, 0 is nothing, and -1 is down
msg = mode+": " + str(value)
if (oldValue != value):
psm.screen.termPrintAt(3, msg0)
psm.screen.termPrintAt(4, msg)
if(psm.isKeyPressed() == True):
psm.screen.clearScreen()
IR = EV3InfraredSensor("BAS1", 9) #Turn off detecting
psm.screen.termPrintln("")
psm.screen.termPrintln("Exiting to menu")
doExit = True
change = 0
if(psm.screen.isTouched()): #Change mode if screen is tapped
count = count + 1
if ( count > 2):
count = 0
psm.screen.clearScreen()
psm.screen.termPrintAt(4, "Switching...")
psm.screen.termPrintAt(7, "Touch screen to change mode")
psm.screen.termPrintAt(8, "Press Go to stop program")
change = 1
示例7: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
# History:
# 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.termPrintln("PiStorms ")
psm.screen.termPrintln("GO button test:")
psm.screen.termPrintln(" ")
exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintln("Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):
pass
psm.screen.termReplaceLastLine("Go Button is = " +str(psm.isKeyPressed()))
if (psm.screen.checkButton(0,0,320,320)):
psm.screen.termPrintln(" ")
psm.screen.termPrintln("Exiting .....")
exit = True
示例8: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [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
示例9: available
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
socket.setdefaulttimeout(5)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(("8.8.8.8", 53))
return True
except Exception as e: pass
return False
psm.screen.fillRect(0, 0, 320, 240, fill = (0,0,0), display = False)
psm.screen.drawAutoText("Testing internet connection", 20, 30, fill = (255,255,255), size = 23, display = False)
psm.screen.fillRect(20, 80, 320, 240, fill = (0,0,0), display = False)
psm.screen.fillBmp(110, 110, 100, 100, path = currentdir+'/'+'load.png', display = False)
psm.screen.fillRect(0, 0, 1, 1, fill = (0,0,0), display = True)
test = available()
psm.screen.fillRect(0, 0, 320, 240, fill = (0,0,0), display = False)
if test:
psm.screen.drawAutoText("You are connected", 35, 20, fill = (0,255,0), size = 25, display = False)
psm.screen.drawAutoText("to the internet!", 35, 50, fill = (0,255,0), size = 25, display = False)
psm.screen.fillBmp(120, 85, 80, 80, path = currentdir+'/'+'wifi_green.png', display = False)
else:
psm.screen.drawAutoText("You are not connected", 35, 20, fill = (255,0,0), size = 25, display = False)
psm.screen.drawAutoText("to the internet!", 35, 50, fill = (255,0,0), size = 25, display = False)
psm.screen.fillBmp(130, 95, 60, 60, path = currentdir+'/'+'x_red.png', display = False)
psm.screen.drawButton(35, 170, width = 250, height = 40, text="Continue", display=False)
psm.screen.fillRect(0, 0, 1, 1, fill = (0,0,0), display = True)
exit = False
while not exit:
cont = psm.screen.checkButton(35, 170, 250, 40)
if cont or psm.isKeyPressed(): exit = True
示例10: open
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
opt.append([tim,i.split("\n",1)[1],int(i.split("\n")[0])])
lt = tim
opt = opt[::-1]
except Exception as e:
error = True
with open(config_file, "w+") as f:
f.write("")
if error or len(opt) == 0:
psm.screen.drawAutoText("You have no Wi-Fi", 35, 20, fill = (255,0,0), size = 22, display = False)
psm.screen.drawAutoText("configurations backups", 35, 50, fill = (255,0,0), size = 22, display = False)
psm.screen.drawButton(35, 170, width = 250, height = 40, text="Continue", display=False)
psm.screen.fillRect(0, 0, 1, 1, fill = (0,0,0), display = True)
while True:
cont = psm.screen.checkButton(35, 170, 250, 40)
if cont or psm.isKeyPressed(): sys.exit(0)
# Reload adapter to apply config changes
def reload_adapter():
# Clear the screen and show the loading image
show_loading(up=True)
# Turn off and back on the wlan interface
subprocess.call(["sudo","ifdown","wlan0"])
subprocess.call(["sudo","ifup","wlan0"])
def draw_options():
# Clear the screen
psm.screen.fillRect(0, 0, 320, 240, (0,0,0))
psm.screen.drawAutoText("Revert WiFi configuration", 20, 10, fill = (255,0,0), size = 24, display = False)
psm.screen.drawButton(20, 45, width = 150, height = 35, text=" <", display=False)
psm.screen.drawButton(170, 45, width = 150, height = 35, text=" >", display=False)
示例11: sleep
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
psm.BBM1.setSpeedSync(SPEED)
sleep(0.1)
psm.BAM1.float()
psm.BAM2.float()
psm.BBM1.float()
psm.BBM2.float()
if __name__ == '__main__':
psm.BAM1.resetPos()
ramp(RAMP_UP)
while not psm.isKeyPressed():
psm.screen.termPrintln('waiting')
psm.screen.clearScreen()
psm.screen.termPrintln('starting!')
for i in xrange(5):
psm.led(1, 255, 0, 0)
sleep(0.8)
psm.led(1, 0, 0, 0)
sleep(0.2)
psm.screen.clearScreen()
ramp(RAMP_MID)
sleep(0.5)
示例12: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
--START BLOCKS--
PHhtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+PGJsb2NrIHR5cGU9InZhcmlhYmxlc19zZXQiIGlkPSJhQW0lfkhpZ1MqdWNrKHR4X11JRyIgeD0iMCIgeT0iMCI+PGZpZWxkIG5hbWU9IlZBUiI+c3Vtb3NlbnNvcjwvZmllbGQ+PGNvbW1lbnQgcGlubmVkPSJ0cnVlIiBoPSI4NSI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Pjx2YWx1ZSBuYW1lPSJzaXplIj48c2hhZG93IHR5cGU9Im1hdGhfbnVtYmVyIiBpZD0iVXpkZk5fP10uVHBsemdKUXBCVUkiPjxmaWVsZCBuYW1lPSJOVU0iPjUwPC9maWVsZD48L3NoYWRvdz48L3ZhbHVlPjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9zdGF0ZW1lbnQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L3N0YXRlbWVudD48L2Jsb2NrPjwvbmV4dD48L2Jsb2NrPjwvbmV4dD48L2Jsb2NrPjwveG1sPg==
e193a87b5d9d2a5cb558efa27c0a1d36f2f2a11d44da1aff62bfbcb2e1712fed
--END BLOCKS--
"""
from PiStorms import PiStorms
import MsDevices
sumosensor = None
old_zone = None
str1 = None
psm = PiStorms()
sumoeyes_BAS1 = MsDevices.SumoEyes(psm.BAS1)
# Attach a NXTSumoEyes to Port BAS1 of PiStorms.
# Start the program from PiStorms on Screen
# Browser and press GO button to terminate.
sumosensor = sumoeyes_BAS1
sumosensor.setRange(sumosensor.LONG_RANGE)
while not bool(psm.isKeyPressed()):
old_zone = str1
str1 = sumosensor.detectObstactleZone(True)
if str1 != old_zone:
psm.screen.clearScreen(True)
psm.screen.drawAutoText(str1, 40, 40, fill = (255, 0, 0), size = 50, display = True)
示例13: str
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
if (addr != 0x34 and addr != 0x35 and addr != 0x36 and addr != 0x37):
i2c = ms_explorerlib.Explorer(addr)
found = i2c.ping(0x00)
print ">>01 found: " + str(found)
if ( found > 0 ):
if ( (addr%2) == 0 ):
# print only the even addresses.
psm.screen.termPrintAt(line, "Device: " + i2c.GetDeviceId()[:6] +" " + (str(hex(addr))))
line = line + 1
if (count > 2000):
found = 5
else:
addr = 0x00
return found
bye = False
while(not exit):
explorer = psm.screen.checkButton(75, 95,width=85,height=40)
if(psm.isKeyPressed()): bye = True
if(explorer == True):
psm.screen.termPrintAt(1, "Searching (Go to cancel) ...")
psm.BAS1.activateCustomSensorI2C()
f = explore()
if ( f == -1):
psm.screen.termPrintAt(8, "Done, Explore again ")
if(bye == True):
psm.screen.termPrintAt(5, "Exiting to menu")
exit = True
time.sleep(.1)
示例14: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Tap and hold the screen 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('GO button state')
plt.title('GO Button')
plt.grid(True)
plt.ylim((-0.05, 1.05)) # set y-axis range, off by a bit so the line isn't right on the edge of the graph
axis = plt.gca() # get current axis
data = np.empty(0)
image = tempfile.NamedTemporaryFile() # we will be overwriting this same file
while not psm.screen.isTouched():
data = np.append(data, psm.isKeyPressed()) # add a data point with the current GO button state
if axis.lines: axis.lines.pop() # if there's already a line on the graph (old), remove it
lines = plt.plot(data[-20:], color="blue") # plot the last 20 data points on the graph (new line)
plt.tight_layout() # make sure the entire plot fits on screen
plt.savefig(image.name, format="png")
psm.screen.fillBmp(0,0, 320,240, image.name)
示例15: disconnect_question
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import isKeyPressed [as 别名]
answer = disconnect_question()
if answer: disconnect()
# Redraw
draw_options()
draw_connections(ssids, page)
# Change the page
if next: page += 1
elif prev:
page -= 1
if page < 0: page = (len(ssids)-1) / 4
elif refresh:
show_loading()
available = Cell.all(wlan_interface)
ssids = get_available()
# Redraw connections if changed
if next or prev or refresh: shown = draw_connections(ssids, page)
# Connect to a chosen network
if label1 and len(shown) > 0: connect(shown[0][0],shown[0][1],shown[0][2])
if label2 and len(shown) > 1: connect(shown[1][0],shown[1][1],shown[1][2])
if label3 and len(shown) > 2: connect(shown[2][0],shown[2][1],shown[2][2])
if label4 and len(shown) > 3: connect(shown[3][0],shown[3][1],shown[3][2])
# Redraws options and available connections
if (label1 and len(shown) > 0) or (label2 and len(shown) > 1) or (label3 and len(shown) > 2) or (label4 and len(shown) > 3):
draw_options()
shown = draw_connections(ssids, page)
# Exit
if(psm.isKeyPressed()): exit = True