src/doord.py
changeset 13 684ac329e7da
parent 12 6f6c8df37897
equal deleted inserted replaced
12:6f6c8df37897 13:684ac329e7da
    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.22
    43     doorbell_on_state = 6.0 < analog_value and analog_value <= 6.22
    44 
    44 
    45     if analog_value < 7.59:
    45     if analog_value < 7.55:
    46         print("doorbell analog value: {}; ringing: {}; ring range: (6.0, 6.22]".format(analog_value, doorbell_on_state))
    46         print("doorbell analog value: {}; ringing: {}; ring range: (6.0, 6.22]".format(analog_value, doorbell_on_state))
    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")