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