當前位置: 首頁>>代碼示例>>Python>>正文


Python GPIO.cleanup方法代碼示例

本文整理匯總了Python中gpio_pins.GPIO.cleanup方法的典型用法代碼示例。如果您正苦於以下問題:Python GPIO.cleanup方法的具體用法?Python GPIO.cleanup怎麽用?Python GPIO.cleanup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gpio_pins.GPIO的用法示例。


在下文中一共展示了GPIO.cleanup方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: poweroff

# 需要導入模塊: from gpio_pins import GPIO [as 別名]
# 或者: from gpio_pins.GPIO import cleanup [as 別名]
def poweroff(wait=1, block=False):
    """
    Powers off the Raspberry Pi from a new thread.
    
    @type wait: int or float
    @param wait: number of seconds to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Powering off...')
        except Exception:
            pass
        subprocess.Popen(['poweroff'])
    else:
        t = Thread(target=poweroff, args=(wait, True))
        t.start()
開發者ID:aocana,項目名稱:SIP,代碼行數:29,代碼來源:helpers.py

示例2: reboot

# 需要導入模塊: from gpio_pins import GPIO [as 別名]
# 或者: from gpio_pins.GPIO import cleanup [as 別名]
def reboot(wait=1, block=False):
    """
    Reboots the Raspberry Pi from a new thread.
    
    @type wait: int
    @param wait: length of time to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Rebooting...')
        except Exception:
            pass
        subprocess.Popen(['reboot'])
    else:
        t = Thread(target=reboot, args=(wait, True))
        t.start()
開發者ID:aocana,項目名稱:SIP,代碼行數:29,代碼來源:helpers.py

示例3: restart

# 需要導入模塊: from gpio_pins import GPIO [as 別名]
# 或者: from gpio_pins.GPIO import cleanup [as 別名]
def restart(wait=1, block=False):
    """
    Restarts the software from a new thread.
    
    @type wait: int
    @param wait: length of time to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        report_restart()
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            gv.logger.info(_('Restarting...'))
        except Exception:
            pass
        subprocess.Popen('service sip restart'.split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
開發者ID:bkoblenz,項目名稱:SIP,代碼行數:30,代碼來源:helpers.py

示例4: poweroff

# 需要導入模塊: from gpio_pins import GPIO [as 別名]
# 或者: from gpio_pins.GPIO import cleanup [as 別名]
def poweroff(wait=1, block=False):
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Powering off...')
        except Exception:
            pass
        subprocess.Popen(['poweroff'])
    else:
        t = Thread(target=poweroff, args=(wait, True))
        t.start()
開發者ID:ntc490,項目名稱:OSPi,代碼行數:17,代碼來源:helpers.py

示例5: restart

# 需要導入模塊: from gpio_pins import GPIO [as 別名]
# 或者: from gpio_pins.GPIO import cleanup [as 別名]
def restart(wait=1, block=False):
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        try:
            GPIO.cleanup()
        except Exception:
            pass
        time.sleep(wait)
        try:
            print _('Restarting...')
        except Exception:
            pass
        subprocess.Popen('service ospi restart'.split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
開發者ID:ntc490,項目名稱:OSPi,代碼行數:20,代碼來源:helpers.py


注:本文中的gpio_pins.GPIO.cleanup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。