mirror of
https://github.com/bitlair/bitlair_doorduino.git
synced 2025-05-13 12:20:07 +02:00
added: operate the door lock button 3 times, in case it fails to open or close the lock
This commit is contained in:
parent
a258ef73ff
commit
af63990bc9
1 changed files with 16 additions and 21 deletions
|
@ -480,43 +480,38 @@ void ParseCMD(char* cmdbuf, uint8_t cmdbuffill)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TOGGLE_TIME 2500
|
||||||
|
#define BUTTON_TIME 250
|
||||||
|
|
||||||
void ToggleLock()
|
void ToggleLock()
|
||||||
{
|
{
|
||||||
if (g_lockopen)
|
if (g_lockopen)
|
||||||
{
|
{
|
||||||
g_lockopen = false;
|
g_lockopen = false;
|
||||||
Serial.println("closing lock");
|
Serial.println("closing lock");
|
||||||
digitalWrite(PIN_CLOSE, HIGH);
|
for (uint8_t i = 0; i < 3; i++)
|
||||||
DelayLEDs(250);
|
{
|
||||||
digitalWrite(PIN_CLOSE, LOW);
|
digitalWrite(PIN_CLOSE, HIGH);
|
||||||
|
DelayLEDs(BUTTON_TIME);
|
||||||
|
digitalWrite(PIN_CLOSE, LOW);
|
||||||
|
DelayLEDs(TOGGLE_TIME - BUTTON_TIME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_lockopen = true;
|
g_lockopen = true;
|
||||||
Serial.println("opening lock");
|
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++)
|
for (uint8_t i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
//disabled because sounding the horn resets the arduino
|
digitalWrite(PIN_OPEN, HIGH);
|
||||||
//digitalWrite(PIN_HORN, HIGH);
|
DelayLEDs(BUTTON_TIME);
|
||||||
DelayLEDs(500);
|
digitalWrite(PIN_OPEN, LOW);
|
||||||
//disabled because sounding the horn resets the arduino
|
DelayLEDs(TOGGLE_TIME - BUTTON_TIME);
|
||||||
//digitalWrite(PIN_HORN, LOW);
|
|
||||||
DelayLEDs(500);
|
|
||||||
}
|
}
|
||||||
DelayLEDs(7000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DelayLEDs(4000);
|
||||||
|
|
||||||
Serial.println("finished lock action");
|
Serial.println("finished lock action");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue