• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python webiopi.sleep函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webiopi.sleep函数的典型用法代码示例。如果您正苦于以下问题:Python sleep函数的具体用法?Python sleep怎么用?Python sleep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sleep函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:tomorrow56,项目名称:Fritzing,代码行数:7,代码来源:script.py


示例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()
开发者ID:amwallis,项目名称:aurora,代码行数:7,代码来源:lightControl.py


示例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)
开发者ID:robingreig,项目名称:raspi-git,代码行数:26,代码来源:script.py


示例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)
开发者ID:HEG-Arc,项目名称:gelato,代码行数:60,代码来源:kiosk_control.py


示例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)
开发者ID:valurv,项目名称:fiatlux,代码行数:7,代码来源:script.py


示例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)
开发者ID:gerstle,项目名称:TubeController,代码行数:33,代码来源:lightTubes.py


示例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)
开发者ID:tyler43636,项目名称:raspberry-pi-power-controller,代码行数:7,代码来源:webiopi-power-controller.py


示例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)
开发者ID:chucksspencer,项目名称:HoDoor,代码行数:32,代码来源:script.py


示例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)
开发者ID:Thomas-Brothers-Workshop,项目名称:HalloweenPi,代码行数:31,代码来源:cmdscript2014.py


示例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)
开发者ID:galen-elfert,项目名称:catfood01,代码行数:31,代码来源:script.py


示例11: loop

def loop():
    while True:
        try:
            updatedb()
            webiopi.sleep(1)
        except:
            continue
开发者ID:HelloClarice,项目名称:ClariceNet,代码行数:7,代码来源:script.py


示例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
开发者ID:Shane-Lester,项目名称:Lights-with-arduino,代码行数:8,代码来源:script.py


示例13: testIO

def testIO():
#Relays
  n = 0
  while n < 16:
    relay.digitalWrite(n, ON)
    webiopi.sleep(.5)
    relay.digitalWrite(n, OFF)
    n = n + 1
开发者ID:Thomas-Brothers-Workshop,项目名称:HalloweenPi,代码行数:8,代码来源:cmdscript2013.py


示例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
开发者ID:Shane-Lester,项目名称:Lights-with-arduino,代码行数:8,代码来源:script.py


示例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)
开发者ID:Sassinak,项目名称:RPiScoreboard,代码行数:8,代码来源:scriptpwm.py


示例16: loop

def loop():
    # gives CPU some time before looping again
    #print "\n LIGHT_value = %d\n" %(GPIO.digitalRead(LIGHT))
    if (GPIO.digitalRead(SWITCH) == GPIO.LOW):
        GPIO.digitalWrite(LIGHT, GPIO.LOW)
		
    if (GPIO.digitalRead(SWITCH) == GPIO.HIGH):
        GPIO.digitalWrite(LIGHT, GPIO.HIGH)
    webiopi.sleep(1)
开发者ID:LeMaker,项目名称:webio-lemaker,代码行数:9,代码来源:script.py


示例17: loop

def loop():
	global restart
	OFF = GPIO.digitalRead(SWITCH)
	if(OFF and not restart):
		GPIO.digitalWrite(LED, 1)
		#restartRPIHelper()
		restart = True
		webiopi.debug('restart')
	webiopi.sleep(.4)
开发者ID:cristu97,项目名称:Explorator-Pi,代码行数:9,代码来源:control.py


示例18: get_done

def get_done():
    print("spotter start")
    newest = max(glob.iglob('*.[j][p][g]'), key=os.path.getctime)
    cmd = "sudo ./deepbelief  {}  > try6.txt & ".format(newest)
    proc = subprocess.Popen(cmd, shell=True)
    cmd2 = "cp {} raju2.png".format(newest)
    proc2 = subprocess.Popen(cmd2, shell=True)
    webiopi.sleep(10)
    print("spotter stop")
开发者ID:scientistnobee,项目名称:Raspberry-Pi-Spotter,代码行数:9,代码来源:cambot.py


示例19: defaultPosition

def defaultPosition():
	global time_stamp
	if time_stamp <= time.time() - 0.2 and (CURRENT_ANGLE != DEFAULT_ANGLE):
		time_stamp = time.time()
		global CURRENT_ANGLE
		CURRENT_ANGLE = DEFAULT_ANGLE
		GPIO.pulseRatio(SERVO, 1)
		GPIO.pulseAngle(SERVO,DEFAULT_ANGLE)
		webiopi.sleep(0.5)
		GPIO.pulseRatio(SERVO, 0)
开发者ID:alfort74,项目名称:FireExtinguishSystem,代码行数:10,代码来源:control-motors.py


示例20: PWMthread

def PWMthread(pin,DC,sec,delay):
  #Handel delay if needed
  if (str(delay) != "0"):
    webiopi.sleep(float(delay))
  #Write out PWM to to DC
  pwm.pwmWriteFloat(int(pin),float(DC))
  #If interval needed then wait and toggle
  if (str(sec) != "0"):
    webiopi.sleep(float(sec))
    pwm.pwmWriteFloat(int(pin),0.0)
开发者ID:Thomas-Brothers-Workshop,项目名称:HalloweenPi,代码行数:10,代码来源:cmdscript2014.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python parser.parse函数代码示例发布时间:2022-05-26
下一篇:
Python webiopi.debug函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap