interface PI

Dependencies:   mbed LCD_DISCO_F469NI TS_DISCO_F469NI F469_GUI BSP_DISCO_F469NI

main.cpp

Committer:
zigdrix
Date:
2019-10-17
Revision:
2:7002787e2ab1
Parent:
1:450d80728151
Child:
3:273047c393bd

File content as of revision 2:7002787e2ab1:

#include "mbed.h"
#include "stm32469i_discovery.h"
#include "TS_DISCO_F469NI.h"
#include "LCD_DISCO_F469NI.h"
#include "F469_GUI.hpp"

//#define TIME                              // Time for toggle the LED (seconds)

Timeout timeout;                            // Create the Timeout object
DigitalOut leds[] = {(LED1), (LED2), (LED3), (LED4)};
/*DigitalOut led2(LED1, 0);
DigitalOut led3(LED1, 0);
DigitalOut led4(LED1, 0);*/

int num,cont=0;
float TIME=1,x;

void timer_interrupt()
{
    cont++;
    if(num==3) leds[cont] = !leds[cont];                             // Toggle the LED state
    if(cont==3) cont=-1;
    
    timeout.attach(&timer_interrupt, TIME); // Set again the timer timeout for next iterations
}

int main(){
    int a;
    
    BSP_LED_Init(DISCO_LED_BLUE);
    
    Label obj10(400, 2, "Felipe", Label::CENTER, Font24);   //escreve textos 
    Label obj11(400, 40, "Gomes", Label::CENTER, Font24);   //escreve textos
    
    //Button button1(10, 90, 120, 100, "1");
    
    
    const int NUMBER_BUTTONS = 3;   //Número de botões
    const string STR1[NUMBER_BUTTONS] = {"ON", "OFF","?"};  //string que vai nos botões
    //cria botão na tela,(inicio em x, inicio em Y, largura do botão, altura do botão, número de botões
    //                    nome do botão,distãncia dos botões em x, distãncia dos botões em y, número de colunas,
    //                    número de colunas, número de linhas, fonte do texto, cor do texto, cores dos estados do botão)
    ButtonGroup bGroup1(30, 90, 150, 150,  NUMBER_BUTTONS, STR1, 40, 5, 3, 1,   
                        Font24, LCD_COLOR_WHITE, 0xFF003538, 0xFFB70068, 0xFFFF7FFF);
                        
    //NumericLabel<int> bTouch(600, 112, Label::LEFT, Font12, LCD_COLOR_MAGENTA);//label para numeros
    
    Label bTouch(600, 112, Label::LEFT, Font24, LCD_COLOR_MAGENTA);
    
    
    //ButtonGroup bGroup2(160, 150, 66, 40,  3, (string[]){"0", "1", "2"}, 5, 5, 3);
    //bGroup2.InactivateAll();
    
    //ButtonGroup bGroup3(10, 150, 66, 40,  2, (string[]){"ON", "OFF"}, 0, 0, 2);
    //bGroup3.TouchedColor(0);
    
    
    //desenha uma barra gráfica horizontal(inicioX, inicioY, Largura, valor mínimo, Valor maximo, valor inicial, 
    //para criar uma barra gráfica vertical utiliza a função barH
    SeekBar barH(100, 300, 400, 0, 100, 50, "0", "", "100");
    NumericLabel<float> numLabel1(250, 270, "%5.1f", barH.GetValue());
    NumericLabel<float> numLabel2(250, 320, "%5.1f", (float)barH.GetValue());
    NumericLabel<float> numLabel3(600, 205);//?
    
    
    timeout.attach(&timer_interrupt, TIME); // Set the timer interrupt service rutine (ISR) and the time for the timeout (in seconds)
    for(a=0;a<4;a++)leds[a]=1;
    while(true){
        if (bGroup1.GetTouchedNumber(num))
        if(num==0){
            bTouch.Draw("ON");
            BSP_LED_On(DISCO_LED_BLUE);
            for(a=0;a<3;a++)leds[a]=1;
        }
        else if(num==1){
            bTouch.Draw("OFF");
            BSP_LED_Off(DISCO_LED_BLUE);
            for(a=0;a<3;a++)leds[a]=1;
        }
        else if(num==2){
            num=3;
            TIME=x/100;
            bTouch.Draw("TROLADO");
            timeout.attach(&timer_interrupt, x/100); // Set again the timer timeout for next iterations
        } 
        
        
        
        if (barH.Slide())
        {
            numLabel1.Draw("%5.1f", barH.GetValue());
            x = barH.GetValue();
            numLabel2.Draw("%5.1f", x);
            numLabel3.Draw("%5.3f ms", x/100);            
        }       
    }
}