示例#1
0
def toggle(relay_num, log=True, max_duration=None):
    pin = relays[relay_num]
    new_state = not bool(GPIO.input(pin))
    GPIO.output(pin, new_state)
    cancel_timer(relay_num)
    if new_state == ON and max_duration is not None:
        timers[relay_num] = util.delay(off, max_duration, [relay_num], {"log_extra": "via timer"})
    if log:
        log_action(relay_num, "toggle %s" % ('off' if new_state == OFF else 'on'))
    return new_state
示例#2
0
文件: gpio.py 项目: mscalora/garage
def toggle(relay_num, log=True, max_duration=None):
    pin = relays[relay_num]
    new_state = not bool(GPIO.input(pin))
    GPIO.output(pin, new_state)
    cancel_timer(relay_num)
    if new_state == ON and max_duration is not None:
        timers[relay_num] = util.delay(off, max_duration, [relay_num],
                                       {"log_extra": "via timer"})
    if log:
        log_action(relay_num,
                   "toggle %s" % ('off' if new_state == OFF else 'on'))
    return new_state
示例#3
0
文件: gpio.py 项目: mscalora/garage
def get_relay(relay_num):
    pin = relays[relay_num]
    return 'on' if GPIO.input(pin) == ON else 'off'
示例#4
0
文件: gpio.py 项目: mscalora/garage
def get_sensor(sensor_num):
    return GPIO.input(sensors[sensor_num])
示例#5
0
def get_relay(relay_num):
    pin = relays[relay_num]
    return 'on' if GPIO.input(pin) == ON else 'off'
示例#6
0
def get_sensor(sensor_num):
    return GPIO.input(sensors[sensor_num])