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()
|
||||
{
|
||||
if (g_lockopen)
|
||||
{
|
||||
g_lockopen = false;
|
||||
Serial.println("closing lock");
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
{
|
||||
digitalWrite(PIN_CLOSE, HIGH);
|
||||
DelayLEDs(250);
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue