From 2a83667a68bea1094052eb0b06ff0a608d55262d Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Wed, 23 Nov 2011 20:22:36 +0000 Subject: [PATCH] =?utf8?q?sch=C3=B6ner=20aber=20auch=20nicht=20funktioneller?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- firmware/tuer.pde | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/firmware/tuer.pde b/firmware/tuer.pde index 3feb058..20639fe 100644 --- a/firmware/tuer.pde +++ b/firmware/tuer.pde @@ -80,19 +80,16 @@ boolean is_closed() //**********// -void init_ajar() +boolean get_ajar_status() // shut = true, ajar = false { - pinMode(AJAR_PIN, INPUT); // set pin to input - digitalWrite(AJAR_PIN, HIGH); // turn on pullup resistors - ajar_last_state = digitalRead(AJAR_PIN); + return (digitalRead(AJAR_PIN) == LOW); } -boolean get_ajar_status() // shut = true, ajar = false +void init_ajar() { - if(digitalRead(AJAR_PIN)) - return false; - - return true; + pinMode(AJAR_PIN, INPUT); // set pin to input + digitalWrite(AJAR_PIN, HIGH); // turn on pullup resistors + ajar_last_state = get_ajar_status(); } //**********// @@ -624,7 +621,9 @@ void loop() } } boolean a = get_ajar_status(); - if(a != ajar_last_state) + if (a != ajar_last_state) + { print_status(); - ajar_last_state = a; + ajar_last_state = a; + } } -- 1.7.10.4