Added a new Brand "Kamoona" to be used for other applications that are not a known brand.

Fork of RemoteIR by Shinichiro Nakamura

Revision:
14:257b2f794dc4
Parent:
11:268cc2ab63bd
Child:
15:793c2aa484b1
--- a/ReceiverIR.cpp	Sun Apr 19 19:11:32 2015 +0000
+++ b/ReceiverIR.cpp	Mon Apr 27 07:33:55 2015 +0000
@@ -63,6 +63,7 @@
     const int nbits = data.bitcount;
     const int nbytes = data.bitcount / 8 + (((data.bitcount % 8) != 0) ? 1 : 0);
     *format = data.format;
+    printf("Number of bytes received is : %d\n",nbytes);
     for (int i = 0; i < nbytes; i++) {
         buf[i] = data.buffer[i];
     }
@@ -241,8 +242,10 @@
 
 void ReceiverIR::isr_rise(void) {
     LOCK();
+    //printf("In ReceiverIR function\n");
     switch (work.state) {
         case Idle:
+            //printf("Entered Idle State...\n");
             if (0 <= work.c1) {
                 work.c2 = timer.read_us();
                 int a = work.c2 - work.c1;
@@ -250,7 +253,13 @@
                     data.format = RemoteIR::SONY;
                     work.state = Receiving;
                     data.bitcount = 0;
-                } else {
+               } else if (InRange(a, RemoteIR::TUS_KAMOONA * 3)) {
+                    data.format = RemoteIR::KAMOONA;
+                    work.state = Receiving;
+                    //printf("changing state to receiving\n");
+                    data.bitcount = 0; 
+                
+               } else {
                     static const int MINIMUM_LEADER_WIDTH = 150;
                     if (a < MINIMUM_LEADER_WIDTH) {
                         init_state();
@@ -261,6 +270,7 @@
             }
             break;
         case Receiving:
+            //printf("Entered Receving State, data.format is %d\n",data.format);
             if (RemoteIR::NEC == data.format) {
                 work.d1 = timer.read_us();
             } else if (RemoteIR::AEHA == data.format) {
@@ -295,6 +305,37 @@
                 timeout.detach();
                 timeout.attach_us(this, &ReceiverIR::isr_timeout, RemoteIR::TUS_SONY * 4);
 #endif
+            }  
+            else if (RemoteIR::KAMOONA == data.format) {
+                work.d2 = timer.read_us();
+                int a = work.d2 - work.d1;
+                if (InRange(a, RemoteIR::TUS_KAMOONA * 2)) {
+                    data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8));
+                } else if (InRange(a, RemoteIR::TUS_KAMOONA * 1)) {
+                    data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
+                }
+                data.bitcount++;
+#if 0
+                /*
+                 * How do I know the correct length? (6bits, 12bits, 15bits, 20bits...)
+                 * By a model only?
+                 * Please check a specification of your remote controller if you find a problem.
+                 */
+                if (12 <= data.bitcount) {
+                    data.state = Received;
+                    work.c1 = -1;
+                    work.c2 = -1;
+                    work.c3 = -1;
+                    work.d1 = -1;
+                    work.d2 = -1;
+                }
+#else
+                /*
+                 * Set timeout for tail detection automatically.
+                 */
+                timeout.detach();
+                timeout.attach_us(this, &ReceiverIR::isr_timeout, RemoteIR::TUS_KAMOONA * 4);
+#endif
             }
             break;
         case Received: