From af63990bc9fa98b083f23bd529fc834334e678ff Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 20 Dec 2015 22:33:40 +0100 Subject: [PATCH] added: operate the door lock button 3 times, in case it fails to open or close the lock --- bitlair_doorduino/bitlair_doorduino.ino | 37 +++++++++++-------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/bitlair_doorduino/bitlair_doorduino.ino b/bitlair_doorduino/bitlair_doorduino.ino index 49ecd53..79bb7f8 100644 --- a/bitlair_doorduino/bitlair_doorduino.ino +++ b/bitlair_doorduino/bitlair_doorduino.ino @@ -480,43 +480,38 @@ void ParseCMD(char* cmdbuf, uint8_t cmdbuffill) } } +#define TOGGLE_TIME 2500 +#define BUTTON_TIME 250 + void ToggleLock() { if (g_lockopen) { g_lockopen = false; Serial.println("closing lock"); - digitalWrite(PIN_CLOSE, HIGH); - DelayLEDs(250); - digitalWrite(PIN_CLOSE, LOW); + for (uint8_t i = 0; i < 3; i++) + { + digitalWrite(PIN_CLOSE, HIGH); + DelayLEDs(BUTTON_TIME); + digitalWrite(PIN_CLOSE, LOW); + DelayLEDs(TOGGLE_TIME - BUTTON_TIME); + } } else { g_lockopen = true; Serial.println("opening lock"); - digitalWrite(PIN_OPEN, HIGH); - DelayLEDs(250); - digitalWrite(PIN_OPEN, LOW); - } - - if (HasMainsPower()) - { - DelayLEDs(10000); - } - else - { for (uint8_t i = 0; i < 3; i++) { - //disabled because sounding the horn resets the arduino - //digitalWrite(PIN_HORN, HIGH); - DelayLEDs(500); - //disabled because sounding the horn resets the arduino - //digitalWrite(PIN_HORN, LOW); - DelayLEDs(500); + digitalWrite(PIN_OPEN, HIGH); + DelayLEDs(BUTTON_TIME); + digitalWrite(PIN_OPEN, LOW); + DelayLEDs(TOGGLE_TIME - BUTTON_TIME); } - DelayLEDs(7000); } + DelayLEDs(4000); + Serial.println("finished lock action"); }