IR

Dependencies:   RemoteIR mbed

Files at this revision

API Documentation at this revision

Comitter:
anykovar
Date:
Tue Jan 10 22:23:27 2017 +0000
Parent:
0:0b36c6926bfd
Commit message:
IR;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0b36c6926bfd -r c81bb0a316d4 main.cpp
--- a/main.cpp	Tue Jan 10 22:21:15 2017 +0000
+++ b/main.cpp	Tue Jan 10 22:23:27 2017 +0000
@@ -34,55 +34,55 @@
     return ir_tx.setData(format, buf, bitlength);
 }
 
-int main(void)
+int main(void) {
+    
+while (1)
 {
+    uint8_t buf1[32];
+    uint8_t buf2[32];
+    int bitlength1;
+    int bitlength2;
+    RemoteIR::Format format;
+
+    memset(buf1, 0x00, sizeof(buf1));
+    memset(buf2, 0x00, sizeof(buf2));
+
+    {
+        bitlength1 = receive(&format, buf1, sizeof(buf1));
+        if (bitlength1 < 0) {
+            continue;
+        }
+    }
+
+#if TEST_LOOP_BACK
+    wait_ms(100);
 
-    while (1) {
-        uint8_t buf1[32];
-        uint8_t buf2[32];
-        int bitlength1;
-        int bitlength2;
-        RemoteIR::Format format;
+    {
+        bitlength1 = transmit(format, buf1, bitlength1);
+        if (bitlength1 < 0) {
+            continue;
+        }
+    }
+
+    wait_ms(100);
 
-        memset(buf1, 0x00, sizeof(buf1));
-        memset(buf2, 0x00, sizeof(buf2));
+    {
+        bitlength2 = receive(&format, buf2, sizeof(buf2));
+        if (bitlength2 < 0) {
+            continue;
+        }
+    }
 
-        {
-            bitlength1 = receive(&format, buf1, sizeof(buf1));
-            if (bitlength1 < 0) {
+    wait_ms(100);
+
+    {
+        for (int i = 0; i < sizeof(buf1); i++) {
+            if (buf1[i] != buf2[i]) {
+                wait(1);
                 continue;
             }
         }
-
-#if TEST_LOOP_BACK
-        wait_ms(100);
-
-        {
-            bitlength1 = transmit(format, buf1, bitlength1);
-            if (bitlength1 < 0) {
-                continue;
-            }
-        }
-
-        wait_ms(100);
-
-        {
-            bitlength2 = receive(&format, buf2, sizeof(buf2));
-            if (bitlength2 < 0) {
-                continue;
-            }
-        }
-
-        wait_ms(100);
-
-        {
-            for (int i = 0; i < sizeof(buf1); i++) {
-                if (buf1[i] != buf2[i]) {
-                    wait(1);
-                    continue;
-                }
-            }
-        }
+    }
 #endif
-    }
+}
 }
\ No newline at end of file