summaryrefslogtreecommitdiff
path: root/n/asserv/src/counter.c
diff options
context:
space:
mode:
Diffstat (limited to 'n/asserv/src/counter.c')
-rw-r--r--n/asserv/src/counter.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/n/asserv/src/counter.c b/n/asserv/src/counter.c
index 7fcfac5..774a9c8 100644
--- a/n/asserv/src/counter.c
+++ b/n/asserv/src/counter.c
@@ -23,6 +23,11 @@
*
* }}} */
+/** Define to 1 to reverse the left counter. */
+#define COUNTER_REVERSE_LEFT 1
+/** Define to 1 to reverse the right counter. */
+#define COUNTER_REVERSE_RIGHT 0
+
/** Forward and reverse counter values. */
static uint8_t counter_left_frw, counter_left_rev,
counter_right_frw, counter_right_rev;
@@ -79,7 +84,11 @@ counter_poll (void)
uint8_t c;
/* Read left counter. */
c = TCNT2;
+#if COUNTER_REVERSE_LEFT == 0
if (PINE & _BV (4))
+#else
+ if (!(PINE & _BV (4)))
+#endif
{
PORTD &= ~0x40;
counter_left_frw += c - counter_left_old;
@@ -92,7 +101,11 @@ counter_poll (void)
counter_left_old = c;
/* Read right counter. */
c = TCNT3L;
+#if COUNTER_REVERSE_RIGHT == 0
if (PINE & _BV (5))
+#else
+ if (!(PINE & _BV (5)))
+#endif
{
PORTD &= ~0x20;
counter_right_frw += c - counter_right_old;