improved car detection

Wed, 26 Jun 2013 11:37:23 +0200

author
Malte Bayer <mbayer@neo-soft.org>
date
Wed, 26 Jun 2013 11:37:23 +0200
changeset 141
467e6351986e
parent 140
f910ad6ed0b6
child 142
a933d44a6edc

improved car detection

blackbox/interrupts.c file | annotate | diff | comparison | revisions
--- a/blackbox/interrupts.c	Wed Jun 26 11:11:04 2013 +0200
+++ b/blackbox/interrupts.c	Wed Jun 26 11:37:23 2013 +0200
@@ -122,9 +122,9 @@
     // car0 detector
     uint16_t tmp = 0;
     car0_new = TCNT1; // get current counter
-    if (car0_old < car0_new) {
+    if ((car0 == 0) && (car0_old < car0_new)) {
         // calculate difference
-        if (car0 == 0) tmp = car0_new-car0_old;
+        tmp = car0_new-car0_old;
         if ( (tmp > 54) && (tmp < 74) ) car0 = 1;
         if ( (tmp > 118) && (tmp < 138) ) car0 = 2;
         if ( (tmp > 186) && (tmp < 206) ) car0 = 3;
@@ -139,9 +139,9 @@
     // car1 detector
     uint16_t tmp = 0;
     car1_new = TCNT1; // get current counter
-    if (car1_old < car1_new) {
+    if ((car1 == 0) && (car1_old < car1_new)) {
         // calculate difference
-        if (car1 == 0) tmp = car1_new-car1_old;
+        tmp = car1_new-car1_old;
         if ( (tmp > 54) && (tmp < 74) ) car1 = 1;
         if ( (tmp > 118) && (tmp < 138) ) car1 = 2;
         if ( (tmp > 186) && (tmp < 206) ) car1 = 3;

mercurial