ccvcv

Dependencies:   TextLCD mbed

Fork of PRACTICA3 by compartido

Revision:
1:591fea5f363b
Parent:
0:73a5b9689b80
Child:
2:0ef1b1712e64
--- a/main.cpp	Fri Nov 10 07:45:30 2017 +0000
+++ b/main.cpp	Fri Nov 10 08:48:12 2017 +0000
@@ -1,18 +1,83 @@
 #include "mbed.h"
+// librería LCD
+
+#define vector 100
+//TextLCD (6 puertos, TextLCD::LCD16x2); rs,e,d4-d7
 
-PwmOut mypwm(PWM_OUT);
-
-DigitalOut myled(LED1);
+InterruptIn Sw (); //pulsador en el puerto
+AnalogIn leer (); // leer del puerto
+Ticker muestreo;
+Ticker visualizar;
+int contt=0;
+int contm=0;
+int dato=0,
+int bufferlleno=0;
+int flag;
+float buffer1 [vector];
+float buffer2 [vector];
+float Vrms;
+float suma;
+float muestra;
 
-int main() {
-    
-    mypwm.period_ms(10);
-    mypwm.pulsewidth_ms(1);
-  
-    printf("pwm set to %.2f %%\n", mypwm.read() * 100);
-    
-    while(1) {
-        myled = !myled;
-        wait(1);
+void temporizador 
+
+{
+    if (flag) 
+    {
+        
+        }
+        contt++;
+        if (contt==100)
+        {
+            contt =0;
+            flag =!flag;
+            bufferlleno=0;
+            }
+    }
+
+void boton()
+{
+    dato++;
+    if (dato>1) {
+        dato = 0;
     }
 }
+
+void LCD()
+{
+    lcd.cls();
+    switch (dato) {
+        case 0;
+            lcdprintf(); //Vrms :\n%3.3f V,Vrms
+            break;
+        case 1;
+            lcdprintf(); //
+            break;
+    }
+}
+
+int main()
+{
+
+    contador = 0 ;
+
+    muestreo.attach_us (&temporizador,200);
+    visualizar.attach (&mostrar, 1);
+    Sw.rise(&boton);
+
+    //printf("pwm set to %.2f %%\n", mypwm.read() * 100);
+
+    while(1) {
+        if (bufferlleno) {
+            suma=0;
+            for (contm=0; contm<100: contm++) {
+                if (flag==1) {
+                    muestra=buffer1[contm];
+                } else {
+                    muestra=buffer2[contm];
+                }
+            }
+        }
+
+    }
+}