ESTOP Support

This commit is contained in:
Matthew Frost 2023-06-21 23:18:55 +02:00
parent 0a5c1a30f6
commit c791a42b7f

View file

@ -10,12 +10,12 @@ void unlockDoor(bool silent) {
granted_beep(); granted_beep();
} }
#endif #endif
#ifdef RELAY1 #ifdef RELAY1
#ifdef RELAY1_REVERSED #ifdef RELAY1_REVERSED
controlRelay(RELAY1_PIN,true); controlRelay(RELAY1_PIN,true);
#else #else
controlRelay(RELAY1_PIN,false); controlRelay(RELAY1_PIN,false);
#endif #endif
#endif #endif
#ifdef SERIAL_DEBUG #ifdef SERIAL_DEBUG
Serial.println("door unlocked"); Serial.println("door unlocked");
@ -32,14 +32,11 @@ void unlockDoor(bool silent) {
void lockDoor() { void lockDoor() {
#ifdef RELAY1 #ifdef RELAY1
#ifdef RELAY1_REVERSED
controlRelay(RELAY1_PIN,false);
#ifdef RELAY1_REVERSED #else
controlRelay(RELAY1_PIN,false); controlRelay(RELAY1_PIN,true);
#else #endif
controlRelay(RELAY1_PIN,true);
#endif
#endif #endif
#ifdef SERIAL_DEBUG #ifdef SERIAL_DEBUG
Serial.println("door locked"); Serial.println("door locked");
@ -59,11 +56,19 @@ void toggleDoor() {
#ifdef RELAY1 #ifdef RELAY1
int relayState = digitalRead(RELAY1_PIN); int relayState = digitalRead(RELAY1_PIN);
// Toggle the relay based on the current state // Toggle the relay based on the current state
if (relayState == LOW) { #ifdef RELAY1_REVERSED
lockDoor(); if (relayState == HIGH) {
} else { lockDoor();
unlockDoor(false); } else {
} unlockDoor(false);
}
#else
if (relayState == LOW) {
lockDoor();
} else {
unlockDoor(false);
}
#endif
#endif #endif
} }