Skip to content

Commit 3ebeb20

Browse files
committed
check latch state on open ref #6
1 parent 2c51435 commit 3ebeb20

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: Electric Imp Device Code.nut

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ agent.on("btn", function(data)
3434
switch (data.cmd) {
3535
case "open":
3636
gateOpen.write(0);
37-
if (latchTimer) imp.cancelwakeup(latchTimer);
38-
latchTimer = imp.wakeup(1, releaseOpen);
37+
if (! latchState) // Only do this if gate is not already latched open to prevent canceling latchTimer instance
38+
{
39+
if (latchTimer) imp.cancelwakeup(latchTimer);
40+
latchTimer = imp.wakeup(1, releaseOpen);
41+
}
3942
server.log("Open command received");
4043
break;
4144

0 commit comments

Comments
 (0)