本文整理汇总了Python中webiopi.sleep函数的典型用法代码示例。如果您正苦于以下问题:Python sleep函数的具体用法?Python sleep怎么用?Python sleep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sleep函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setPcOn
def setPcOn():
if GPIO.digitalRead(PWSTATUS) == GPIO.LOW:
GPIO.digitalWrite(LIGHT, GPIO.HIGH)
# wait 1 sec
webiopi.sleep(1)
GPIO.digitalWrite(LIGHT, GPIO.LOW)
return true
示例2: loop
def loop():
global RAINBOW_CYCLE
if RAINBOW_CYCLE == False:
# gives CPU some time before looping again
webiopi.sleep(1)
elif RAINBOW_CYCLE == True:
rainbowStateMachine()
示例3: loop
def loop():
# retrieve current datetime
now = datetime.datetime.now()
# toggle light ON all days at the correct time
if ((now.hour == HOUR_ON) and (now.minute == 0) and (now.second == 0)):
if (GPIO.digitalRead(FRONT) == GPIO.HIGH):
GPIO.digitalWrite(FRONT, GPIO.LOW)
# toggle light ON all days at the correct time
if ((now.hour == HOUR_ON) and (now.minute == 0) and (now.second == 20)):
if (GPIO.digitalRead(BACK) == GPIO.HIGH):
GPIO.digitalWrite(BACK, GPIO.LOW)
# toggle light OFF
if ((now.hour == HOUR_OFF) and (now.minute == 0) and (now.second == 0)):
if (GPIO.digitalRead(FRONT) == GPIO.LOW):
GPIO.digitalWrite(FRONT, GPIO.HIGH)
# toggle light OFF
if ((now.hour == HOUR_OFF) and (now.minute == 0) and (now.second == 00)):
if (GPIO.digitalRead(BACK) == GPIO.LOW):
GPIO.digitalWrite(BACK, GPIO.HIGH)
# gives CPU some time before looping again
webiopi.sleep(1)
示例4: loop
def loop():
global door_open, kiosk_open, lock_open, lock_opened, t1, t2, t3
lock_opened = mc.get("lock_opened")
kiosk_open = mc.get("kiosk_open")
# retrieve current datetime
now = datetime.datetime.now()
if GPIO.digitalRead(T1) == GPIO.LOW and t1:
t1 = False
# Drawer 1 closed
if GPIO.digitalRead(T1) == GPIO.HIGH and not t1:
t1 = True
# Drawer 1 open
if GPIO.digitalRead(T2) == GPIO.LOW and t2:
t2 = False
# Drawer 2 closed
if GPIO.digitalRead(T2) == GPIO.HIGH and not t2:
t2 = True
# Drawer 2 open
if GPIO.digitalRead(T3) == GPIO.LOW and t3:
t3 = False
# Drawer 3 closed
if GPIO.digitalRead(T3) == GPIO.HIGH and not t3:
t3 = True
# Drawer 3 open
if not kiosk_open:
if GPIO.digitalRead(DOOR) == GPIO.HIGH and not door_open:
door_open = True
# We have an intrusion
if GPIO.digitalRead(DOOR) == GPIO.LOW and door_open:
door_open = False
# Intrusion ended
if kiosk_open:
if GPIO.digitalRead(DOOR) == GPIO.HIGH and not door_open:
door_open = True
# Kiosk opened
if GPIO.digitalRead(DOOR) == GPIO.LOW and door_open:
door_open = False
kiosk_open = False
mc.set("kiosk_open", kiosk_open)
if GPIO.digitalRead(LOCK) == GPIO.LOW:
GPIO.digitalWrite(LOCK, GPIO.HIGH)
lock_open = False
# Kiosk closed
if GPIO.digitalRead(LOCK) == GPIO.LOW and lock_opened < datetime.datetime.now() - datetime.timedelta(seconds=6):
GPIO.digitalWrite(LOCK, GPIO.HIGH)
lock_open = False
# gives CPU some time before looping again
webiopi.sleep(1)
示例5: loop
def loop():
global Takki1Status, Takki2Status, Takki3Status, Takki4Status
#readStatus(Takki1,Takki1Status,Takki1Safn)
#readStatus(Takki2,Takki2Status,Takki2Safn)
#readStatus(Takki3,Takki3Status,Takki3Safn)
readStatus(Takki4,Takki4Status,Takki4Safn)
webiopi.sleep(0.3)
示例6: loop
def loop():
global schedule
global currentShow
global showStartTime
#webiopi.debug("loop... schedule count: " + str(len(schedule)))
if len(schedule) > 0:
#webiopi.debug("running schedule")
currentTime = int(time.time())
if (currentShow == -1) or ((currentTime - showStartTime) > schedule[currentShow].length):
# currentShow == -1 means we're starting a schedule for the first time... give time to fade out of previous
if (currentShow == -1):
time.sleep(2)
currentShow += 1
if (currentShow >= len(schedule)):
currentShow = 0
showStartTime = currentTime
webiopi.debug("next show: " + schedule[currentShow].program + " for " + str(schedule[currentShow].length) + " seconds");
if (schedule[currentShow].program != 'fadeout'):
serial.writeString("program ")
else:
serial.writeString("push ")
serial.writeString(schedule[currentShow].program)
if (schedule[currentShow].program != 'fadeout'):
serial.writeString(" fadein")
serial.writeString("\r")
webiopi.sleep(1)
示例7: loop
def loop():
""" Loop run by WebIOPi """
webiopi.sleep(0.05)
button_push = not GPIO.digitalRead(BUTTON)
if button_push:
togglePower()
webiopi.sleep(0.5)
示例8: loop
def loop():
global lastRead
global currentRead
global secondsOpen
# Read the state of the switch
currentRead = GPIO.digitalRead(SWITCHPIN)
# If the state of the switch has changed, record the event
if currentRead != lastRead:
print('Door state has changed, recording event')
recordEvent(currentRead)
lastRead = currentRead
# If the door is open, keep track of how long. Send out a notification every 15 mins until closed.
if currentRead == DOOROPEN and AUTONOTIFICATIONS == True:
secondsOpen += SLEEPTIME
if secondsOpen > OPENWARNINGTIMEINMINS*60:
print('Door has been open for ' + str(secondsOpen) + ' seconds. Sending notification')
# Fetch the last two records to send off with the notification
lastTwo = getRecords(2)
sendNotification('{' + lastTwo + '}')
# Reset the timer so we can send again in another 15 mins
secondsOpen = 0
else:
secondsOpen = 0
# gives CPU some time before looping again
webiopi.sleep(SLEEPTIME)
示例9: Relaythread
def Relaythread(pin,status,sec,delay):
relay = relay1
#Select relay object and set logic pin
if int(pin) <= 8:
relay = relay1
inPin = int(pin)-1
elif int(pin) <= 16:
relay = relay2
inPin = int(pin)-9
elif int(pin) <= 24:
relay = relay3
inPin = int(pin)-17
else:
webiopi.debug(tempList[0] + " is not a valid command")
return "ERROR - " + tempList[0] + " is not a valid command"
#Handle delay in needed
if (str(delay) != "0"):
webiopi.sleep(float(delay))
#Write desired status
webiopi.debug("Writing to pin " + str(inPin))
relay.digitalWrite(inPin, status)
#If interval needed then wait and toggle
if (str(sec) != "0"):
webiopi.sleep(float(sec))
if (status == ON):
relay.digitalWrite(inPin, OFF)
else:
relay.digitalWrite(inPin, ON)
示例10: loop
def loop():
# retrieve current datetime
# now = datetime.datetime.now()
global status, catID, catAte, catFull
doorOpen = False
while (not doorOpen):
if (serial.available() > 0):
data = serial.readString()
if (data[0] == "o"):
catID = int(data[1])
if (catAte[catID] < catDiet[catID]):
serial.writeString("1")
status = data
doorOpen = True
else:
serial.writeString("0")
webiopi.sleep(0.5)
while (doorOpen):
if (serial.available() > 0):
data = serial.readString()
if (data[0] == "c"):
catAte[catID] = round((catAte[catID] + float(data[1:])), 2)
if(catAte[catID] > catDiet[catID]):
catFull[catID] = 1
else:
catFull[catID] = 0
status = "c:" + str(catFull[0]) + ":" + str(catAte[0]) + ":" + str(catFull[1]) + ":"+ str(catAte[1])
doorOpen = False
webiopi.sleep(1)
示例11: loop
def loop():
while True:
try:
updatedb()
webiopi.sleep(1)
except:
continue
示例12: allOff
def allOff(number):
seq= int(number)
for f in range(seq):
lightoff(1,f+1)
webiopi.sleep(0.1)
#lightoff(1,f+1)
return
示例13: testIO
def testIO():
#Relays
n = 0
while n < 16:
relay.digitalWrite(n, ON)
webiopi.sleep(.5)
relay.digitalWrite(n, OFF)
n = n + 1
示例14: allOn
def allOn(number):
#global AUTOMAN
seq= int(number)
for f in range(seq):
light(1,f+1)
webiopi.sleep(0.1)
#light(1,f+1)
return
示例15: loop
def loop():
#PWM tests
GPIO.pwmWrite(LED0, 0.90)
#webiopi.sleep(0.25)
GPIO.pwmWrite(LED0, 0.30)
#webiopi.sleep(0.2)
GPIO.pwmWrite(LED0, 0.70)
webiopi.sleep(0.2)