GartenwasserGPIO.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Gartenwasser 作者: bgewehr 项目源码 文件源码
def loop():
    """
    The main loop in which we mow the lawn.
    """
    print 'GPIO daemon started'
    while True:
        for PIN in PINS:
            index = [y[0] for y in PINS].index(PIN[0])
            pin = PINS[index][0]
            oldstate = PINS[index][1]
            newstate = GPIO.input(pin)
            if newstate != oldstate:
                mqttc.publish(MQTT_TOPIC_OUT % pin, payload=newstate, qos=MQTT_QOS, retain=MQTT_RETAIN)
                PINS[index][1] = newstate
        time.sleep(.8)


# Use the signal module to handle signals
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号