ccvcv

Dependencies:   TextLCD mbed

Fork of PRACTICA3 by compartido

main.cpp

Committer:
carlospomar
Date:
2017-11-10
Revision:
1:591fea5f363b
Parent:
0:73a5b9689b80
Child:
2:0ef1b1712e64

File content as of revision 1:591fea5f363b:

#include "mbed.h"
// librería LCD

#define vector 100
//TextLCD (6 puertos, TextLCD::LCD16x2); rs,e,d4-d7

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;

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];
                }
            }
        }

    }
}