keuzeproject mdev 1ITF groep: E3

Fork of RemoteIR by Shinichiro Nakamura

Files at this revision

API Documentation at this revision

Comitter:
1ITF3
Date:
Mon Feb 01 10:20:31 2016 +0000
Parent:
11:268cc2ab63bd
Commit message:
Test code TV RC6 bij gecodeerd

Changed in this revision

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
TransmitterIR.h Show annotated file Show diff for this revision Revisions of this file
diff -r 268cc2ab63bd -r 0767bcde0d32 RemoteIR.h
--- a/RemoteIR.h	Mon Sep 20 00:54:59 2010 +0000
+++ b/RemoteIR.h	Mon Feb 01 10:20:31 2016 +0000
@@ -17,13 +17,15 @@
         NEC_REPEAT,
         AEHA,
         AEHA_REPEAT,
-        SONY
+        SONY,
+        RC6
     } Format;
 
     static const int TUS_NEC = 562;
     static const int TUS_AEHA = 425;
     static const int TUS_SONY = 600;
-
+    static const int TUS_RC6 = 444;
+   
 private:
     RemoteIR();
 };
diff -r 268cc2ab63bd -r 0767bcde0d32 TransmitterIR.cpp
--- a/TransmitterIR.cpp	Mon Sep 20 00:54:59 2010 +0000
+++ b/TransmitterIR.cpp	Mon Feb 01 10:20:31 2016 +0000
@@ -68,6 +68,8 @@
     work.leader = 0;
     work.data = 0;
     work.trailer = 0;
+    
+
 
     data.format = format;
     data.bitlength = bitlength;
@@ -89,6 +91,10 @@
             ticker.detach();
             ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_SONY);
             break;
+        case RemoteIR::RC6:
+            ticker.detach();
+            ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_RC6);
+            break;
     }
 
     UNLOCK();
@@ -111,6 +117,7 @@
                  */
                 static const int LEADER_NEC_HEAD = 16;
                 static const int LEADER_NEC_TAIL = 8;
+
                 if (work.leader < LEADER_NEC_HEAD) {
                     tx.write(0.5);
                 } else {
@@ -120,6 +127,21 @@
                 if ((LEADER_NEC_HEAD + LEADER_NEC_TAIL) <= work.leader) {
                     work.state = Data;
                 }
+            } else if (data.format == RemoteIR::RC6){
+                //RC6
+                static const int LEADER_RC6_HEAD = 6;
+                static const int LEADER_RC6_TAIL = 2;
+                static const int LEADER_RC6_TOGGLE= 888;
+                if (work.leader < LEADER_RC6_HEAD) {
+                    tx.write(0.5);
+
+                } else {
+                    tx.write(0.0);
+                }
+                work.leader++;
+                if ((LEADER_RC6_HEAD + LEADER_RC6_TAIL) <= work.leader) {
+                    work.state = Toggle;
+                }
             } else if (data.format == RemoteIR::AEHA) {
                 /*
                  * AEHA.
@@ -153,6 +175,23 @@
             } else {
             }
             break;
+            work.state = Leader;
+            
+        case Toggle:
+                    if (0 != (data.buffer[work.bitcount / 8] & (1 << work.bitcount % 8))) {
+                        if (1 <= work.data) {
+                    tx.write(0.5);
+                        } else {
+                            work.data++;
+                        }
+
+                            
+                        } else {
+                            work.data++;
+                        }
+                    
+                
+            break;
         case Data:
             if (data.format == RemoteIR::NEC) {
                 /*
@@ -182,6 +221,28 @@
                 if (data.bitlength <= work.bitcount) {
                     work.state = Trailer;
                 }
+            } else if (data.format == RemoteIR::RC6) {
+                //RC6
+
+                    if (0 != (data.buffer[work.bitcount / 8] & (1 << work.bitcount % 8))) {
+                        if (1 <= work.data) {
+                    tx.write(0.5);
+                        } else {
+                            work.data++;
+                        }
+                    } else {
+                        if (0 <= work.data) {
+                            tx.write(0.0);
+                            
+                        } else {
+                            work.data++;
+                        }
+                    
+                }
+                if (data.bitlength <= work.bitcount) {
+                    work.state = Trailer;
+                }
+                
             } else if (data.format == RemoteIR::AEHA) {
                 /*
                  * AEHA.
@@ -205,7 +266,9 @@
                         } else {
                             work.data++;
                         }
+                        
                     }
+                    
                 }
                 if (data.bitlength <= work.bitcount) {
                     work.state = Trailer;
@@ -258,6 +321,20 @@
                     work.state = Idle;
                     //ticker.detach();
                 }
+            } else if (data.format == RemoteIR::RC6) {
+                //RC6
+                static const int TRAILER_RC6_HEAD = 0;
+                static const int TRAILER_RC6_TAIL = 1;
+                if (work.trailer < TRAILER_RC6_HEAD) {
+                    tx.write(0.5);
+                } else {
+                    tx.write(0.0);
+                }
+                work.trailer++;
+                if ((TRAILER_RC6_HEAD + TRAILER_RC6_TAIL) <= work.trailer) {
+                    work.state = Idle;
+                    //ticker.detach();
+                }
             } else if (data.format == RemoteIR::AEHA) {
                 /*
                  * AEHA.
diff -r 268cc2ab63bd -r 0767bcde0d32 TransmitterIR.h
--- a/TransmitterIR.h	Mon Sep 20 00:54:59 2010 +0000
+++ b/TransmitterIR.h	Mon Feb 01 10:20:31 2016 +0000
@@ -34,7 +34,8 @@
         Idle,
         Leader,
         Data,
-        Trailer
+        Trailer,
+        Toggle
     } State;
 
     /**