Add 10 second timeout to armed state

master
Tanner Collin 6 years ago
parent b14dabc721
commit 78c2a99d30
  1. 11
      firmware/firmware.ino

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

Loading…
Cancel
Save