src/doord.py
changeset 11 a70d948427d3
parent 10 38c4094d0d57
child 12 6f6c8df37897
equal deleted inserted replaced
10:38c4094d0d57 11:a70d948427d3
    38         automationhat.relay.on() if command == "unlock" else automationhat.relay.off()
    38         automationhat.relay.on() if command == "unlock" else automationhat.relay.off()
    39 
    39 
    40 
    40 
    41 def read_doorbell(thread_local):
    41 def read_doorbell(thread_local):
    42     analog_value = automationhat.analog.one.read()
    42     analog_value = automationhat.analog.one.read()
    43     doorbell_on_state = 6.0 < analog_value and analog_value < 6.3
    43     doorbell_on_state = 5.9 < analog_value and analog_value < 6.5
    44 
    44 
    45     if doorbell_on_state:
    45     if doorbell_on_state:
    46         print("doorbell analog value: {}".format(analog_value))
    46         print("doorbell analog value: {}".format(analog_value))
    47 
    47 
    48     if doorbell_on_state != thread_local.doorbell_on_state:
    48     if doorbell_on_state != thread_local.doorbell_on_state:
    49         thread_local.doorbell_on_state = doorbell_on_state
    49         thread_local.doorbell_on_state = doorbell_on_state
    50         print("doorbell_on") if doorbell_on_state else print("doorbell_off")
    50         print("doorbell on") if doorbell_on_state else print("doorbell off")
    51 
    51 
    52 
    52 
    53 if __name__ == "__main__":
    53 if __name__ == "__main__":
    54     main()
    54     main()