TAREA

Dependencies:   Debounced Pulse1 TextLCD mbed

Dependents:   IRDA

Fork of irda1 by Gustavo Ramirez

Files at this revision

API Documentation at this revision

Comitter:
sagilar
Date:
Wed Apr 29 14:57:28 2015 +0000
Parent:
3:7a5b5eea31c9
Commit message:
IRDA

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Apr 29 14:44:33 2015 +0000
+++ b/main.cpp	Wed Apr 29 14:57:28 2015 +0000
@@ -18,7 +18,7 @@
 const int head_H = 2916; //+20% medida con osciloscopio en microsegundos
 const int head_L = 1944;//-20%  medida con osciloscopio
 int i=0;
-int resi=0,n1,n2;
+int resi=0,n1,n2,n;
 float unos,ceros,desc;
 int dec=0;
 char hex[3];
@@ -58,8 +58,11 @@
      dato = irda.read_low_us(); //leer un bit de datos que es pulso abajo en este control 
          num[i]=dato;
             //wait_us(300); 
+            if (i<7){//la mitad de los bits
+                
      dato2 = irda.read_high_us();//Para calcular los tiempos de descanso
-     desca[i]=dato2;
+          desca[i]=dato2;
+     }
      }
      wait(0.5);
       for(i=0;i<(num_bits-1);++i){  
@@ -83,7 +86,7 @@
          // lcd.printf("0");
       } 
       }
-       desc=desc/(num_bits);
+       desc=desc/(num_bits/2);
       //Convierte decimal a hexadecimal
        unos=unos/n1;
       ceros=ceros/n2;
@@ -101,6 +104,7 @@
      else if (resi==14) hex[i]='E';
      else if (resi==15) hex[i]='F';
     }
+    n=n1+n2+1;
       
        lcd.cls();
             lcd.printf("El header dura:\nH:%d L:%d us",header,header2);
@@ -129,7 +133,7 @@
       }
          if (c==4){
               lcd.cls();
-             lcd.printf("El numero de \nbits es: %d ...",n1+n2+1);
+             lcd.printf("El numero de \nbits es: %d ...",n);
                }
        if (c==5){
               lcd.cls();