interface PI

Dependencies:   mbed LCD_DISCO_F469NI TS_DISCO_F469NI F469_GUI BSP_DISCO_F469NI

Revision:
1:450d80728151
Parent:
0:0a8891401c4f
Child:
2:7002787e2ab1
--- a/main.cpp	Sun Oct 23 16:00:40 2016 +0000
+++ b/main.cpp	Wed Oct 16 22:28:26 2019 +0000
@@ -4,121 +4,76 @@
 #include "LCD_DISCO_F469NI.h"
 #include "F469_GUI.hpp"
 
-int main()
+#define TIME 0.1                              // Time for toggle the LED (seconds)
+
+Timeout timeout;                            // Create the Timeout object
+DigitalOut led1(LED1, 0);
+/*DigitalOut led2(LED1, 0);
+DigitalOut led3(LED1, 0);
+DigitalOut led4(LED1, 0);*/
+
+int num;
+
+void timer_interrupt()
 {
+    if(num==2) led = !led;                             // Toggle the LED state
+    timeout.attach(&timer_interrupt, TIME); // Set again the timer timeout for next iterations
+}
+
+int main(){
     BSP_LED_Init(DISCO_LED_BLUE);
     
-    Label obj10(400, 2, "Dome: GUI parts, 2016/07/23, 12:24", Label::CENTER, Font16);
-    Label obj11(400, 20, "Button, ButtonGroup, Label, NumericLabel, BlinkLabel,",
-                Label::CENTER);
-    Label obj12(400, 32, "SeekBar, SeekbarGroup",
-                Label::CENTER);
-
-    Button button1(10, 54, 50, 40, "1");
-    Button button2(62, 54, 50, 40, "2");
-
-    const int NUMBER_BUTTONS = 4;
-    const string STR1[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Activate"};
-    ButtonGroup bGroup1(160, 54, 66, 40,  NUMBER_BUTTONS, STR1, 5, 5, 3, 1,
-                        Font12, LCD_COLOR_WHITE, 0xFF003538, 0xFFB70068, 0xFFFF7FFF);
-    NumericLabel<int> bTouch(240, 112, Label::LEFT, Font12, LCD_COLOR_MAGENTA);
-
-    // Control status of bGroup1
-    ButtonGroup bGroup2(160, 150, 66, 40,  3, (string[]){"0", "1", "2"}, 5, 5, 3);
-    bGroup2.InactivateAll();
+    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);
+    
     
-    // Switching buttons to control barH active or inactive
-    ButtonGroup bGroup3(10, 150, 66, 40,  2, (string[]){"ON", "OFF"}, 0, 0, 2);
-    bGroup3.TouchedColor(0);
-
-    Button doNotTouch(250, 220, 120, 40, "Don't Touch", Font12,
-                      GuiBase::ENUM_TEXT, GuiBase::ENUM_BACK,
-                      LCD_COLOR_DARKGREEN, LCD_COLOR_RED);
-
-    // Using default value for argument (Horizontal)
-    SeekBar barH(20, 250, 200, -5, 5, 0, "-5", "", "5");
-    NumericLabel<float> numLabel1(80, 205, "%5.1f", barH.GetValue());
-    NumericLabel<int> numLabel2(130, 205, "%3d", (int)barH.GetValue());
-    NumericLabel<int> numLabel3(160, 205);
+    //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);
+    
     
-    // SeekbarGroup (vertical)
-    SeekbarGroup barV(410, 130, 121, 2, 45, -6, 6, 2,
-                      SeekBar::Vertical, 0xFFA0FFC0);
-    NumericLabel<float> **numLabel4;
-    numLabel4 = new NumericLabel<float> *[2];
-    for (int n=0; n<2; n++) numLabel4[n] =
-        new NumericLabel<float>(410+n*45, 104, "%4.1f", barV.GetValue(n), Label::CENTER);
-    NumericLabel<int> numLabel5(455, 92, "%1d", barV.GetIntValue(0), Label::CENTER);
-
-    // Test of left-, cenrer-, and right-justified
-    Label leftJustified(420, 54, "ABC", Label::LEFT);
-    Label centerJustified(420, 64, "ABC", Label::CENTER);
-    Label rightJustified1(420, 74, "ABC", Label::RIGHT);
-
-    while (true)
-    {
-        if (button1.Touched()) button2.Draw();
-        if (button2.Touched()) button1.Draw();
-
-        int num;
+    //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<int> numLabel2(250, 320, "%3d", (int)barH.GetValue());
+    NumericLabel<int> numLabel3(160, 205);//?
+    
+    
+    timeout.attach(&timer_interrupt, TIME); // Set the timer interrupt service rutine (ISR) and the time for the timeout (in seconds)
+    while(true){
+        
         if (bGroup1.GetTouchedNumber(num))
-            bTouch.Draw("Button%d touched", num+1);
-        if (num == 3)
-            bGroup2.ActivateAll();
-
-        if (bGroup2.GetTouchedNumber(num))
-        switch (num)
-        {
-            case 0: button1.Activate();
-                    bGroup1.Activate(1);
-                    BSP_LED_On(DISCO_LED_BLUE);
-                    bGroup1.DrawAll();
-                    break;
-            case 1: button1.Inactivate();
-                    bGroup1.Inactivate(1);
-                    BSP_LED_Off(DISCO_LED_BLUE);
-                    break;
-            case 2: bGroup1.EraseAll();//for (int n=0; n<4; n++) bGroup1.Erase(n);
-                    for (int n=0; n<2; n++)
-                    {
-                        barV.Draw(n, 0);    // reset seekbar
-                        numLabel4[n]->Draw("%4.1f", barV.GetValue(n));
-                    }
-                    break;
+        if(num==0){
+            bTouch.Draw("ON");
+            BSP_LED_On(DISCO_LED_BLUE);
+            led=1;
         }
-
-        if (barH.Slide())
-        {
-            numLabel1.Draw("%5.1f", barH.GetValue());
-            int8_t x = (int8_t)barH.GetValue();
-            numLabel2.Draw("%3d", x);
-
-            numLabel3.Draw("%3d", barH.GetIntValue());            
-        }        
-
-        int sbNum;
-        if (barV.GetSlidedNumber(sbNum))
-        {
-            if (sbNum == 0) numLabel4[sbNum]->Draw("%4.1f", barV.GetValue(sbNum));
-            else            numLabel4[sbNum]->Draw("%4.1f", barV.GetValue(sbNum));
-            if (sbNum == 1) numLabel5.Draw("%1d", barV.GetIntValue(sbNum));
+        else if(num==1){
+            bTouch.Draw("OFF");
+            BSP_LED_Off(DISCO_LED_BLUE);
+            led=1;
         }
-        // If "doNotTouch" button touched, trapped into endless loop
-        if (doNotTouch.Touched())
-            BlinkLabel warning(250, 200, "You must reset", Label::LEFT, Font16);
-            
-        // SeekBar active inactive switching
-        if (bGroup3.Touched(0))
-        {
-            barH.Activate();
-            barV.ActivateAll();
-        }
-        if (bGroup3.Touched(1))
-        {
-            barH.Inactivate();
-            barV.InactivateAll();
-        }
-
-        wait(0.02f);
+        else if(num==2){
+            bTouch.Draw("TROLADO");
+        }     
     }
 }
+ 
\ No newline at end of file