当前位置: 首页>>代码示例>>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;未经允许,请勿转载。