A test script for testing a generic IR remote on STM32 NUCLEO

Dependencies:   RemoteIR mbed

Files at this revision

API Documentation at this revision

Comitter:
havebug
Date:
Fri Jul 14 09:59:40 2017 +0000
Parent:
2:35f80e65a141
Commit message:
added indication for continuous pressing of buttons

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 35f80e65a141 -r 29915623fbb0 main.cpp
--- a/main.cpp	Thu Jul 13 11:37:43 2017 +0000
+++ b/main.cpp	Fri Jul 14 09:59:40 2017 +0000
@@ -14,39 +14,41 @@
 
 RemoteIR::Format format;
 uint8_t buf[32];
-int bitcount;
-float DC=0.5;
+int bitcount, decoded;
+double DC=0.5;
 
 int main()
 {
-    my_pwm1.period_ms(10);
+    my_pwm1.period_us(200);
     my_pwm1.write(DC);
     
-    my_pwm2.period_ms(10);
+    my_pwm2.period_us(200);
     my_pwm2.write(DC);
-    
-    
+       
 
     pc.printf("Hello World !\r\n");
     while(1) {
         
         if (ir_rx.getState() == ReceiverIR::Received) {
             bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8);
-            
-            if (bitcount>0){
+            myled=1;
+            if (bitcount>0) {
+                decoded=buf[3];
+                pc.printf("\r\nDecoded: %02X ", buf[3]);
+            }
                 
-                pc.printf("Decoded: %02X \r\n", buf[3]);
+                pc.printf(".");
                 myled = !myled;
                     
-                if (buf[3]==0xE5){
-                    DC = DC+ 0.1;
+                if (decoded==0xE5){
+                    DC = DC+ 0.01;
                     if (DC>1) DC=1;
                 }
-                if (buf[3]==0xD4){
-                    DC = DC- 0.1;
+                if (decoded==0xD4){
+                    DC = DC- 0.01;
                     if (DC<0) DC=0;
                 }    
-                if (buf[3]==0xC3){
+                if (decoded==0xC3){
                     DC = 0.5;
                 }   
                     
@@ -59,10 +61,8 @@
                      pc.printf("%02X", buf[i]);
                     }
                 */
-                
-            }
             
-        }
-
+        } else myled=0;
+        
     }
 }