1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

avr-code now uses doorcmds.h

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
Ralf Ramsauer 2015-09-17 14:59:03 +02:00
parent 5808ef8677
commit 13980b895a

View File

@ -11,6 +11,8 @@
#include "io.h" #include "io.h"
#include "uart.h" #include "uart.h"
#include "../doorcmds.h"
static volatile enum {LOCKED, UNLOCKED} state = LOCKED; static volatile enum {LOCKED, UNLOCKED} state = LOCKED;
static volatile bool schnapper = false; static volatile bool schnapper = false;
@ -23,26 +25,26 @@ void uart_handler(const unsigned char c)
{ {
char retval = c; char retval = c;
switch ((char)c) { switch ((char)c) {
case 'u': case DOOR_CMD_UNLOCK:
state = UNLOCKED; state = UNLOCKED;
reset_timeout(); reset_timeout();
break; break;
case 'l': case DOOR_CMD_LOCK:
state = LOCKED; state = LOCKED;
break; break;
case 'p': case DOOR_CMD_PING:
break; break;
case 's': case DOOR_CMD_SCHNAPER:
if (state == UNLOCKED) if (state == UNLOCKED)
schnapper = true; schnapper = true;
else else
retval = '?'; retval = '?';
break; break;
case 'i': case DOOR_CMD_STATUS:
retval = (state == LOCKED) ? 'l' : 'u'; retval = (state == LOCKED) ? 'l' : 'u';
break; break;
@ -70,7 +72,7 @@ ISR(INT0_vect)
if (!is_button_lock()) if (!is_button_lock())
goto out; goto out;
uart_putc('L'); uart_putc(DOOR_BUTTON_LOCK);
state = LOCKED; state = LOCKED;
out: out:
@ -87,7 +89,7 @@ ISR(INT1_vect)
if (!is_button_unlock()) if (!is_button_unlock())
goto out; goto out;
uart_putc('U'); uart_putc(DOOR_BUTTON_UNLOCK);
bolzen_off(); bolzen_off();
schnapper_on(); schnapper_on();
@ -128,10 +130,11 @@ int main(void)
if (state == LOCKED) { if (state == LOCKED) {
bolzen_on(); bolzen_on();
schnapper = false; schnapper = false;
if (is_emergency_unlock()) { if (is_emergency_unlock()) {
_delay_ms(200); _delay_ms(200);
if (is_emergency_unlock()) { if (is_emergency_unlock()) {
uart_putc('N'); uart_putc(DOOR_EMERGENCY_UNLOCK);
cli(); cli();
bolzen_off(); bolzen_off();