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

Fork of RemoteIR by Shinichiro Nakamura

Files at this revision

API Documentation at this revision

Comitter:
mskamoona
Date:
Mon Apr 27 07:33:55 2015 +0000
Parent:
12:0651f02169ee
Child:
15:793c2aa484b1
Commit message:
kamoona Model recognized!!

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
--- 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:
--- a/RemoteIR.h	Sun Apr 19 19:11:32 2015 +0000
+++ b/RemoteIR.h	Mon Apr 27 07:33:55 2015 +0000
@@ -18,16 +18,16 @@
         AEHA,
         AEHA_REPEAT,
         SONY,
-        Samsung,
-        Samsung_REPEAT,
-        Nikon,
+        KAMOONA,
+        
     } Format;
 
     static const int TUS_NEC = 562;
     static const int TUS_AEHA = 425;
     static const int TUS_SONY = 600;
-    static const int TUS_Samsung = 546;
-    static const int TUS_Nikon = 25;
+    static const int TUS_KAMOONA = 600;
+    
+   
 
 private:
     RemoteIR();
--- a/TransmitterIR.cpp	Sun Apr 19 19:11:32 2015 +0000
+++ b/TransmitterIR.cpp	Mon Apr 27 07:33:55 2015 +0000
@@ -89,14 +89,11 @@
             ticker.detach();
             ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_SONY);
             break;
-        case RemoteIR::Samsung:
+        case RemoteIR::KAMOONA:
             ticker.detach();
-            ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_Samsung);
+            ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_KAMOONA);
             break;    
-        case RemoteIR::Nikon:
-            ticker.detach();
-            ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_Nikon);
-            break;
+        
     }
 
     UNLOCK();
@@ -158,39 +155,25 @@
                 if ((LEADER_SONY_HEAD + LEADER_SONY_TAIL) <= work.leader) {
                     work.state = Data;
                 }
-            } else if (data.format == RemoteIR::Samsung) {
+            } else if (data.format == RemoteIR::KAMOONA) {
                 /*
                  * SONY.
                  */
-                static const int LEADER_Samsung_HEAD = 8;
-                static const int LEADER_Samsung_TAIL = 8;
-                if (work.leader < LEADER_Samsung_HEAD) {
+                static const int LEADER_KAMOONA_HEAD = 8;
+                static const int LEADER_KAMOONA_TAIL = 0;
+                if (work.leader < LEADER_KAMOONA_HEAD) {
                     tx.write(0.5);
                 } else {
                     tx.write(0.0);
                 }
                 work.leader++;
-                if ((LEADER_Samsung_HEAD + LEADER_Samsung_TAIL) <= work.leader) {
+                if ((LEADER_KAMOONA_HEAD + LEADER_KAMOONA_TAIL) <= work.leader) {
                     work.state = Data;
                 }    
-            } else if (data.format == RemoteIR::Nikon) {
-                /*
-                 * Nikon.
-                 */
-                static const int LEADER_Nikon_HEAD = 0;
-                static const int LEADER_Nikon_TAIL = 0;
-                if (work.leader < LEADER_Nikon_HEAD) {
-                    tx.write(0.5);
-                } else {
-                    tx.write(0.0);
-                }
-                work.leader++;
-                if ((LEADER_Nikon_HEAD + LEADER_Nikon_TAIL) <= work.leader) {
-                    work.state = Data;
-                }
             } else {
             }
             break;
+            
         case Data:
             if (data.format == RemoteIR::NEC) {
                 /*
@@ -276,24 +259,24 @@
                 if (data.bitlength <= work.bitcount) {
                     work.state = Trailer;
                 }
-            }else if (data.format == RemoteIR::Samsung) {
+            }else if (data.format == RemoteIR::SONY) {
                 /*
-                 * Samsung.
+                 * KAMOONA.
                  */
                 if (work.data == 0) {
-                    tx.write(0.5);
+                    tx.write(0.0);
                     work.data++;
                 } else {
-                    tx.write(0.0);
+                    tx.write(0.5);
                     if (0 != (data.buffer[work.bitcount / 8] & (1 << work.bitcount % 8))) {
-                        if (1 <= work.data) {
+                        if (2 <= work.data) {
                             work.bitcount++;
                             work.data = 0;
                         } else {
                             work.data++;
                         }
                     } else {
-                        if (3 <= work.data) {
+                        if (1 <= work.data) {
                             work.bitcount++;
                             work.data = 0;
                         } else {
@@ -303,7 +286,8 @@
                 }
                 if (data.bitlength <= work.bitcount) {
                     work.state = Trailer;
-                } else {
+                }
+            } else {
             }
             break;
         case Trailer:
@@ -355,19 +339,19 @@
                     work.state = Idle;
                     //ticker.detach();
                 }
-            }else if (data.format == RemoteIR::Samsung) {
+            }else if (data.format == RemoteIR::KAMOONA) {
                 /*
-                 * Samsung.
+                 * KAMOONA.
                  */
-                static const int TRAILER_Samsung_HEAD = 1;
-                static const int TRAILER_Samsung_TAIL = 55;
-                if (work.trailer < TRAILER_Samsung_HEAD) {
+                static const int TRAILER_KAMOONA_HEAD = 0;
+                static const int TRAILER_KAMOONA_TAIL = 0;
+                if (work.trailer < TRAILER_KAMOONA_HEAD) {
                     tx.write(0.5);
                 } else {
                     tx.write(0.0);
                 }
                 work.trailer++;
-                if ((TRAILER_Samsung_HEAD + TRAILER_Samsung_TAIL) <= work.trailer) {
+                if ((TRAILER_KAMOONA_HEAD + TRAILER_KAMOONA_TAIL) <= work.trailer) {
                     work.state = Idle;
                     //ticker.detach();
                 }
@@ -378,5 +362,5 @@
             break;
     }
     UNLOCK();
-}
-}
+
+}
\ No newline at end of file