|
|
|
@ -41,6 +41,7 @@ typedef struct __attribute__((packed)) cardData { |
|
|
|
|
#define LED_PIN_OFF !LED_PIN_ON |
|
|
|
|
|
|
|
|
|
#define DELAY_TIME 10 |
|
|
|
|
#define LOCK_ARMED_TIMEOUT 1000 |
|
|
|
|
#define COMM_LOCK_IDLE_TIME 50 |
|
|
|
|
#define COMM_CARD_IDLE_TIME 1000 |
|
|
|
|
#define LED_ARMED_BLINK_TIME 50 |
|
|
|
@ -247,6 +248,10 @@ void relayOff() { digitalWrite(RELAY_PIN, RELAY_OPEN); } |
|
|
|
|
|
|
|
|
|
void processLockState() |
|
|
|
|
{ |
|
|
|
|
static uint16_t lockArmedTimeoutCount; |
|
|
|
|
|
|
|
|
|
if (lockState != LOCK_ARMED) lockArmedTimeoutCount = 0; |
|
|
|
|
|
|
|
|
|
switch (lockState) { |
|
|
|
|
case LOCK_OFF: |
|
|
|
|
if (LEDState != LED_ERROR) LEDState = LED_OFF; |
|
|
|
@ -266,6 +271,7 @@ void processLockState() |
|
|
|
|
if (LEDState != LED_ERROR) LEDState = LED_ARMED; |
|
|
|
|
|
|
|
|
|
relayOff(); |
|
|
|
|
lockArmedTimeoutCount++; |
|
|
|
|
|
|
|
|
|
if (redButton()) { |
|
|
|
|
if (LOGGING) Serial.println("[INFO] Unarming interlock."); |
|
|
|
@ -274,6 +280,11 @@ void processLockState() |
|
|
|
|
if (LOGGING) Serial.println("[INFO] On button pressed."); |
|
|
|
|
lockState = LOCK_ON_PRESSED; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (lockArmedTimeoutCount > LOCK_ARMED_TIMEOUT) { |
|
|
|
|
if (LOGGING) Serial.println("[INFO] Arming timed out, disarming."); |
|
|
|
|
lockState = LOCK_OFF; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case LOCK_ON_PRESSED: |
|
|
|
|
if (redButton()) { |
|
|
|
|