summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2013-11-16 22:04:52 +0000
committerBernhard Tittelbach <xro@realraum.at>2013-11-16 22:04:52 +0000
commite620b94a707aacaef0a4d612f25a75cb332c56ee (patch)
tree2661d4fc70b6edac4b20bd2ec485adfda8f1ccb8
parentrun over limit to avoid wrong manual movement detection (diff)
gas leak alarm
git-svn-id: https://svn.spreadspace.org/avr/trunk@247 aa12f405-d877-488e-9caf-2d797e2a1cc7
-rw-r--r--usb-ajar/usb-ajar.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/usb-ajar/usb-ajar.c b/usb-ajar/usb-ajar.c
index c6ccee5..507c87f 100644
--- a/usb-ajar/usb-ajar.c
+++ b/usb-ajar/usb-ajar.c
@@ -104,11 +104,17 @@ int main(void)
PIN_HIGH(PORTB, PINB1);
PINMODE_INPUT(DDRB, PINB1);
+ PIN_HIGH(PORTB, PINB0);
+ PINMODE_INPUT(DDRB, PINB0);
+ PIN_LOW(PORTD, PIND7);
+ PINMODE_OUTPUT(DDRD, PIND7);
owi_init(PINC4, &PINC);
char door_ajar = 0;
char last_door_ajar = 0;
+ char gas_leak = 0;
+ char last_gas_leak = 0;
num_temp_sensors_ = ds1820_discover();
uint16_t ms_elapsed = 0;
@@ -139,6 +145,13 @@ int main(void)
led2_off();
}
}
+ gas_leak = ! (PINB & _BV(PINB0));
+ if (gas_leak != last_gas_leak)
+ {
+ if (gas_leak)
+ printf("GasLeakAlert\r\n");
+ last_gas_leak = gas_leak;
+ }
anyio_task();
if (door_ajar) {
@@ -155,6 +168,8 @@ int main(void)
if (ms_elapsed & (1<<14))
{
+ if (gas_leak)
+ printf("GasLeakAlert\r\n");
ms_elapsed = 0;
tempToUSB(12);
}