本文整理汇总了Python中gpio_pins.GPIO.output方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.output方法的具体用法?Python GPIO.output怎么用?Python GPIO.output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpio_pins.GPIO
的用法示例。
在下文中一共展示了GPIO.output方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from gpio_pins import GPIO [as 别名]
# 或者: from gpio_pins.GPIO import output [as 别名]
def GET(self):
try:
GPIO.output(pin_relay, GPIO.HIGH) # turn relay on
time.sleep(3)
GPIO.output(pin_relay, GPIO.LOW) # Turn relay off
except Exception:
pass
raise web.seeother('/') # return to home page
示例2: notify_zone_change
# 需要导入模块: from gpio_pins import GPIO [as 别名]
# 或者: from gpio_pins.GPIO import output [as 别名]
def notify_zone_change(name, **kw):
relayGPIO = 10
targetZone = 8
if len(gv.srvals) >= targetZone:
if gv.srvals[targetZone] == 1:
GPIO.output(relayGPIO, GPIO.HIGH)
else:
GPIO.output(relayGPIO, GPIO.LOW)
示例3: GET
# 需要导入模块: from gpio_pins import GPIO [as 别名]
# 或者: from gpio_pins.GPIO import output [as 别名]
def GET(self):
global pi
try:
if gv.use_pigpio:
pi.write(pin_relay, 1)
else:
GPIO.output(pin_relay, GPIO.HIGH) # turn relay on
time.sleep(3)
if gv.use_pigpio:
pi.write(pin_relay, 0)
else:
GPIO.output(pin_relay, GPIO.LOW) # Turn relay off
except Exception, e:
# print "Relay plugin error: ", e
pass
示例4: run
# 需要导入模块: from gpio_pins import GPIO [as 别名]
# 或者: from gpio_pins.GPIO import output [as 别名]
def run(self):
time.sleep(randint(3, 10)) # Sleep some time to prevent printing before startup information
reboot_time = False
once = True
once_two = True
once_three = True
subject = "Reporting from OSPy" # Subject in email
self.add_status('UPS plugin is started.')
last_time = int(time.time())
while True:
try:
dataUPS = get_ups_options() # load data from file
if dataUPS['ups'] != 'off': # if ups plugin is enabled
test = get_check_power()
if not test:
last_time = int(time.time())
if test: # if power line is not active
reboot_time = True # start countdown timer
if once:
if dataUPS['sendeml'] != 'off': # if enabled send email
msg = 'UPS plugin detected fault on power line.' # send email with info power line fault
send_email(self, msg, subject)
once = False
once_three = True
if reboot_time and test:
count_val = int(dataUPS['time'])*60 # value for countdown
actual_time = int(time.time())
self.status = ''
self.add_status('Time to shutdown: ' + str(count_val - (actual_time - last_time)) + ' sec')
if ((actual_time - last_time) >= count_val): # if countdown is 0
last_time = actual_time
test = get_check_power()
if test: # if power line is current not active
self.add_status('Power line is not restore in time -> sends email and shutdown system.')
reboot_time = False
if dataUPS['sendeml'] != 'off': # if enabled send email
if once_two:
msg = 'UPS plugin - power line is not restore in time -> shutdown system!' # send email with info shutdown system
send_email(self, msg, subject)
once_two = False
GPIO.output(pin_ups_down, GPIO.HIGH) # switch on GPIO fo countdown UPS battery power off
self._sleep(4)
GPIO.output(pin_ups_down, GPIO.LOW)
poweroff(1, True) # shutdown system
if not test:
if once_three:
if dataUPS['sendeml'] != 'off': # if enabled send email
msg = 'UPS plugin - power line has restored - OK.'
send_email(self, msg, subject)
once = True
once_two = True
once_three = False
self._sleep(1)
except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info()
err_string = ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback))
self.add_status('UPS plugin encountered error: ' + err_string)
self._sleep(60)
示例5: UPS_Sender
# 需要导入模块: from gpio_pins import GPIO [as 别名]
# 或者: from gpio_pins.GPIO import output [as 别名]
GPIO.setup(pin_power_ok, GPIO.IN, pull_up_down=GPIO.PUD_UP)
except NameError:
pass
try:
if gv.platform == 'pi': # If this will run on Raspberry Pi:
pin_ups_down = 18 # GPIO24
elif gv.platform == 'bo': # If this will run on Beagle Bone Black:
pin_ups_down = " "
except AttributeError:
pass
try:
GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
GPIO.setup(pin_ups_down, GPIO.OUT)
GPIO.output(pin_ups_down, GPIO.LOW)
except NameError:
pass
################################################################################
# Main function loop: #
################################################################################
class UPS_Sender(Thread):
def __init__(self):
Thread.__init__(self)
self.daemon = True
self.start()
self.status = ''