From: Bernhard Tittelbach Date: Wed, 23 Nov 2011 20:22:36 +0000 (+0000) Subject: schöner aber auch nicht funktioneller X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=2a83667a68bea1094052eb0b06ff0a608d55262d;p=svn42.git schöner aber auch nicht funktioneller --- 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; + } }