Fixed version of RemoteIR
Fork of RemoteIR by
Diff: ReceiverIR.cpp
- Revision:
- 11:268cc2ab63bd
- Parent:
- 10:c54fb1204d1e
- Child:
- 12:b6a25dc72156
--- a/ReceiverIR.cpp Fri Sep 17 21:44:01 2010 +0000 +++ b/ReceiverIR.cpp Mon Sep 20 00:54:59 2010 +0000 @@ -95,7 +95,7 @@ if ((Idle != work.state) || ((0 <= work.c1) || (0 <= work.c2) || (0 <= work.c3) || (0 <= work.d1) || (0 <= work.d2))) { cnt++; if (cnt > 50) { -#if 1 +#if 0 printf("# WDT [c1=%d, c2=%d, c3=%d, d1=%d, d2=%d, state=%d, format=%d, bitcount=%d]\n", work.c1, work.c2, @@ -126,14 +126,14 @@ work.c3 = timer.read_us(); int a = work.c2 - work.c1; int b = work.c3 - work.c2; - if (InRange(a, TUS_NEC * 16) && InRange(b, TUS_NEC * 8)) { + if (InRange(a, RemoteIR::TUS_NEC * 16) && InRange(b, RemoteIR::TUS_NEC * 8)) { /* * NEC. */ data.format = RemoteIR::NEC; work.state = Receiving; data.bitcount = 0; - } else if (InRange(a, TUS_NEC * 16) && InRange(b, TUS_NEC * 4)) { + } else if (InRange(a, RemoteIR::TUS_NEC * 16) && InRange(b, RemoteIR::TUS_NEC * 4)) { /* * NEC Repeat. */ @@ -145,14 +145,14 @@ work.c3 = -1; work.d1 = -1; work.d2 = -1; - } else if (InRange(a, TUS_AEHA * 8) && InRange(b, TUS_AEHA * 4)) { + } else if (InRange(a, RemoteIR::TUS_AEHA * 8) && InRange(b, RemoteIR::TUS_AEHA * 4)) { /* * AEHA. */ data.format = RemoteIR::AEHA; work.state = Receiving; data.bitcount = 0; - } else if (InRange(a, TUS_AEHA * 8) && InRange(b, TUS_AEHA * 8)) { + } else if (InRange(a, RemoteIR::TUS_AEHA * 8) && InRange(b, RemoteIR::TUS_AEHA * 8)) { /* * AEHA Repeat. */ @@ -173,9 +173,9 @@ if (RemoteIR::NEC == data.format) { work.d2 = timer.read_us(); int a = work.d2 - work.d1; - if (InRange(a, TUS_NEC * 3)) { + if (InRange(a, RemoteIR::TUS_NEC * 3)) { data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8)); - } else if (InRange(a, TUS_NEC * 1)) { + } else if (InRange(a, RemoteIR::TUS_NEC * 1)) { data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8)); } data.bitcount++; @@ -196,14 +196,14 @@ * Set timeout for tail detection automatically. */ timeout.detach(); - timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_NEC * 5); + timeout.attach_us(this, &ReceiverIR::isr_timeout, RemoteIR::TUS_NEC * 5); #endif } else if (RemoteIR::AEHA == data.format) { work.d2 = timer.read_us(); int a = work.d2 - work.d1; - if (InRange(a, TUS_AEHA * 3)) { + if (InRange(a, RemoteIR::TUS_AEHA * 3)) { data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8)); - } else if (InRange(a, TUS_AEHA * 1)) { + } else if (InRange(a, RemoteIR::TUS_AEHA * 1)) { data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8)); } data.bitcount++; @@ -225,7 +225,7 @@ * Set timeout for tail detection automatically. */ timeout.detach(); - timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_AEHA * 5); + timeout.attach_us(this, &ReceiverIR::isr_timeout, RemoteIR::TUS_AEHA * 5); #endif } else if (RemoteIR::SONY == data.format) { work.d1 = timer.read_us(); @@ -246,7 +246,7 @@ if (0 <= work.c1) { work.c2 = timer.read_us(); int a = work.c2 - work.c1; - if (InRange(a, TUS_SONY * 4)) { + if (InRange(a, RemoteIR::TUS_SONY * 4)) { data.format = RemoteIR::SONY; work.state = Receiving; data.bitcount = 0; @@ -268,9 +268,9 @@ } else if (RemoteIR::SONY == data.format) { work.d2 = timer.read_us(); int a = work.d2 - work.d1; - if (InRange(a, TUS_SONY * 2)) { + if (InRange(a, RemoteIR::TUS_SONY * 2)) { data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8)); - } else if (InRange(a, TUS_SONY * 1)) { + } else if (InRange(a, RemoteIR::TUS_SONY * 1)) { data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8)); } data.bitcount++; @@ -293,7 +293,7 @@ * Set timeout for tail detection automatically. */ timeout.detach(); - timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_SONY * 4); + timeout.attach_us(this, &ReceiverIR::isr_timeout, RemoteIR::TUS_SONY * 4); #endif } break;