]> cloudbase.mooo.com Git - irmp.git/commitdiff
Version 2.9.7: added port to to ESP8266 and TEENSY, added PANASONIC protocol, added...
authorukw <ukw@aeb2e35e-bfc4-4214-b83c-9e8de998ed28>
Wed, 18 Nov 2015 08:31:27 +0000 (08:31 +0000)
committerukw <ukw@aeb2e35e-bfc4-4214-b83c-9e8de998ed28>
Wed, 18 Nov 2015 08:31:27 +0000 (08:31 +0000)
git-svn-id: svn://mikrocontroller.net/irmp@171 aeb2e35e-bfc4-4214-b83c-9e8de998ed28

examples/Arduino/Arduino.ino [moved from examples/Arduino.ino with 56% similarity]

similarity index 56%
rename from examples/Arduino.ino
rename to examples/Arduino/Arduino.ino
index 3738b192ea5bf2021c0f53fa95a322b759781a17..0d2fd1a739142a5ca40857292cda1c76e79360a1 100644 (file)
@@ -43,7 +43,7 @@ void loop()
     IRMP_DATA* data = &irmp_data[act_data];\r
     if (irmp_get_data(data))\r
     {\r
-       led(HIGH);\r
+        led(HIGH);\r
 #if IRMP_PROTOCOL_NAMES == 1\r
         Serial.print(irmp_protocol_names[data->protocol]);\r
         Serial.print(" ");\r
@@ -63,16 +63,16 @@ void loop()
         data->flags = 0;    // reset flags!\r
         int result = irsnd_send_data(data, TRUE);\r
         if (result != 1)\r
-       {\r
-           Serial.println("loop : irsnd_send_data ERROR");\r
-       }\r
-       else\r
-       {\r
-           if (++act_data >= 3)\r
-           {\r
-               act_data = 0;\r
-           } \r
-       }\r
+        {\r
+            Serial.println("loop : irsnd_send_data ERROR");\r
+        }\r
+        else\r
+        {\r
+            if (++act_data >= 3)\r
+            {\r
+                act_data = 0;\r
+            \r
+        }\r
     }\r
 \r
     if (Serial.available() == 18 && readAndCheck('P') && readAndCheck(':'))\r
@@ -81,53 +81,51 @@ void loop()
         data->protocol = readHex() * 16 + readHex();\r
 \r
         if (readAndCheck(' ') && readAndCheck('A') && readAndCheck(':'))\r
-       {\r
-           // read the address\r
-           data->address = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
-\r
-           if (readAndCheck(' ') && readAndCheck('C') && readAndCheck(':'))\r
-           {\r
-               // read the address\r
-               data->command = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
-\r
-               // send ir data\r
-               data->flags = 0;\r
-               int result = irsnd_send_data(data, TRUE);\r
-               if (result)\r
-               {\r
-                   Serial.print("Send IR data: ");\r
-                   Serial.print("P:");\r
-                   Serial.print(data->protocol, HEX);\r
-                   Serial.print(" A:");\r
-                   Serial.print(data->address, HEX);\r
-                   Serial.print(" C:");\r
-                   Serial.print(data->command, HEX);\r
-                   Serial.println("");\r
-\r
-                   if (++act_data >= 3)\r
-                   {\r
-                       act_data = 0;\r
-                   } \r
-               }\r
-           }\r
-       }\r
+        {\r
+            // read the address\r
+            data->address = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
+\r
+            if (readAndCheck(' ') && readAndCheck('C') && readAndCheck(':'))\r
+            {\r
+                // read the address\r
+                data->command = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
+\r
+                // send ir data\r
+                data->flags = 0;\r
+                int result = irsnd_send_data(data, TRUE);\r
+                if (result)\r
+                {\r
+                    Serial.print("Send IR data: ");\r
+                    Serial.print("P:");\r
+                    Serial.print(data->protocol, HEX);\r
+                    Serial.print(" A:");\r
+                    Serial.print(data->address, HEX);\r
+                    Serial.print(" C:");\r
+                    Serial.print(data->command, HEX);\r
+                    Serial.println("");\r
+\r
+                    if (++act_data >= 3)\r
+                    {\r
+                        act_data = 0;\r
+                    \r
+                }\r
+            }\r
+        }\r
     }\r
 }\r
 \r
 /* helper function: attachInterrupt wants void(), but irmp_ISR is uint8_t() */\r
 void timerinterrupt()\r
 {\r
-    // only when tsop dont see the ir_led flashing\r
-    irsnd_ISR();                       // call irsnd ISR\r
-    irmp_ISR();                        // call irmp ISR\r
-\r
-/*\r
-    // do not receive when sending (tsop see the ir_led)\r
-    if (! irsnd_ISR())                 // call irsnd ISR\r
-    {                                  // if not busy...\r
-       irmp_ISR();                     // call irmp ISR\r
+#if 1   // if TSOP receiver can't detect my own IR LED, call both functions:\r
+    irsnd_ISR();                        // call irsnd ISR\r
+    irmp_ISR();                         // call irmp ISR\r
+#else   // if TSOP receiver also detects my own IR LED, don't receive while sending:\r
+    if (! irsnd_ISR())                  // call irsnd ISR\r
+    {                                   // if not busy...\r
+        irmp_ISR();                     // call irmp ISR\r
     }\r
-*/\r
+#endif\r
 }\r
 \r
 static inline void led(int state)\r
@@ -147,14 +145,14 @@ static inline int readHex()
     int c = Serial.read();\r
     if (c >= '0' && c <= '9')\r
     {\r
-       return c - '0';\r
+        return c - '0';\r
     }\r
 \r
     c |= 0x20; // lowercase\r
 \r
     if (c >= 'a' && c <= 'f')\r
     {\r
-       return c + 10 - 'a';\r
+        return c + 10 - 'a';\r
     }\r
 \r
     return -1;\r