z

Dependencies:   BSP_DISCO_L476VG LCD_DISCO_L476VG

main.cpp

Committer:
Leonnn
Date:
2020-06-05
Revision:
4:857fcfaf69fb
Parent:
3:fb87187a09bd
Child:
5:ff9848a77dac

File content as of revision 4:857fcfaf69fb:

#include "mbed.h"
#include "LCD_DISCO_L476VG.h"

LCD_DISCO_L476VG lcd;

Serial pc(SERIAL_TX, SERIAL_RX);
Ticker tick_cadence;
bool flag_envoi = 0;

void interrupt(void){
    flag_envoi = 1;
}

int main(void){
    unsigned char i = 0;
    unsigned char carre = 0;
    unsigned int moy = 0;
    pc.baud(115200);
    unsigned char display[7] = {0};
    
    tick_cadence.attach(&interrupt, 0.01);
    
    while(1){
        carre = i*i/255;
        
        if(i == 255){
            moy = moy/256;
            lcd.Clear();
            sprintf((char*)display,"%d", moy);
            lcd.DisplayString(display);
            //pc.printf("$%d %d %d;",i,carre,moy);
            moy = 0;
        }
        else
            moy += carre;
            
        wait(0.01); 
        i++;
        
        if(flag_envoi){
            pc.printf("$%d %d;",i, carre);
        }
    }
}