本文整理汇总了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()
示例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()
示例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()
示例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()
示例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()