RemoteIR.

Dependents:   RemoteIR_TestProgram SerialGPS_TestProgram StarBoardOrangeExpansion1 Door_Slamming_Device ... more

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Sat Aug 21 04:46:14 2010 +0000
Parent:
2:08836610bd4a
Child:
4:2304646f6ff5
Commit message:

Changed in this revision

ReceiverIR.cpp Show annotated file Show diff for this revision Revisions of this file
RemoteIR.h Show annotated file Show diff for this revision Revisions of this file
TransmitterIR.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/ReceiverIR.cpp	Tue Aug 17 10:37:41 2010 +0000
+++ b/ReceiverIR.cpp	Sat Aug 21 04:46:14 2010 +0000
@@ -29,7 +29,7 @@
     IRQ_DISABLE();
     State s = data.state;
     IRQ_ENABLE();
-    wait_ms(100);
+    wait_ms(10);
     return s;
 }
 
@@ -76,7 +76,7 @@
     if ((Idle != data.state) || ((0 <= work.c1) || (0 <= work.c2) || (0 <= work.c3) || (0 <= work.d1) || (0 <= work.d2))) {
         cnt++;
         if (cnt > 50) {
-#if 0
+#if 1
             printf("# WDT [c1=%d, c2=%d, c3=%d, d1=%d, d2=%d, state=%d, format=%d, bitcount=%d]\n",
                    work.c1,
                    work.c2,
@@ -118,9 +118,14 @@
                     /*
                      * NEC Repeat.
                      */
-                    data.format = RemoteIR::NEC;
+                    data.format = RemoteIR::NEC_REPEAT;
                     data.state = Received;
                     data.bitcount = 0;
+                    work.c1 = -1;
+                    work.c2 = -1;
+                    work.c3 = -1;
+                    work.d1 = -1;
+                    work.d2 = -1;
                 } else if (InRange(a, TUS_AEHA * 8) && InRange(b, TUS_AEHA * 4)) {
                     /*
                      * AEHA.
@@ -132,9 +137,14 @@
                     /*
                      * AEHA Repeat.
                      */
-                    data.format = RemoteIR::AEHA;
+                    data.format = RemoteIR::AEHA_REPEAT;
                     data.state = Received;
                     data.bitcount = 0;
+                    work.c1 = -1;
+                    work.c2 = -1;
+                    work.c3 = -1;
+                    work.d1 = -1;
+                    work.d2 = -1;
                 } else {
                     init_state();
                 }
@@ -150,7 +160,7 @@
                     data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
                 }
                 data.bitcount++;
-#if 1
+#if 0
                 /*
                  * Length of NEC is always 32 bits.
                  */
@@ -167,7 +177,7 @@
                  * Set timeout for tail detection automatically.
                  */
                 timeout.detach();
-                timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_NEC * 12);
+                timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_NEC * 5);
 #endif
             } else if (RemoteIR::AEHA == data.format) {
                 work.d2 = timer.read_us();
@@ -178,7 +188,7 @@
                     data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
                 }
                 data.bitcount++;
-#if 1
+#if 0
                 /*
                  * Typical length of AEHA is 48 bits.
                  * Please check a specification of your remote controller if you find a problem.
@@ -196,7 +206,7 @@
                  * Set timeout for tail detection automatically.
                  */
                 timeout.detach();
-                timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_AEHA * 12);
+                timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_AEHA * 5);
 #endif
             } else if (RemoteIR::SONY == data.format) {
                 work.d1 = timer.read_us();
@@ -245,7 +255,7 @@
                     data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
                 }
                 data.bitcount++;
-#if 1
+#if 0
                 /*
                  * How do we get the correct length? (6bits, 12bits, 15bits, 20bits...)
                  * By a model only?
@@ -264,7 +274,7 @@
                  * Set timeout for tail detection automatically.
                  */
                 timeout.detach();
-                timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_SONY * 10);
+                timeout.attach_us(this, &ReceiverIR::isr_timeout, TUS_SONY * 4);
 #endif
             }
             break;
--- a/RemoteIR.h	Tue Aug 17 10:37:41 2010 +0000
+++ b/RemoteIR.h	Sat Aug 21 04:46:14 2010 +0000
@@ -14,7 +14,9 @@
     typedef enum {
         UNKNOWN,
         NEC,
+        NEC_REPEAT,
         AEHA,
+        AEHA_REPEAT,
         SONY
     } Format;
 
--- a/TransmitterIR.cpp	Tue Aug 17 10:37:41 2010 +0000
+++ b/TransmitterIR.cpp	Sat Aug 21 04:46:14 2010 +0000
@@ -31,7 +31,7 @@
     IRQ_DISABLE();
     State s = work.state;
     IRQ_ENABLE();
-    wait_ms(100);
+    wait_ms(10);
     return s;
 }
 
--- a/mbed.bld	Tue Aug 17 10:37:41 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da