interface PI

Dependencies:   mbed LCD_DISCO_F469NI TS_DISCO_F469NI F469_GUI BSP_DISCO_F469NI

Revision:
2:7002787e2ab1
Parent:
1:450d80728151
Child:
3:273047c393bd
--- a/main.cpp	Wed Oct 16 22:28:26 2019 +0000
+++ b/main.cpp	Thu Oct 17 15:37:17 2019 +0000
@@ -4,23 +4,29 @@
 #include "LCD_DISCO_F469NI.h"
 #include "F469_GUI.hpp"
 
-#define TIME 0.1                              // Time for toggle the LED (seconds)
+//#define TIME                              // Time for toggle the LED (seconds)
 
 Timeout timeout;                            // Create the Timeout object
-DigitalOut led1(LED1, 0);
+DigitalOut leds[] = {(LED1), (LED2), (LED3), (LED4)};
 /*DigitalOut led2(LED1, 0);
 DigitalOut led3(LED1, 0);
 DigitalOut led4(LED1, 0);*/
 
-int num;
+int num,cont=0;
+float TIME=1,x;
 
 void timer_interrupt()
 {
-    if(num==2) led = !led;                             // Toggle the LED state
+    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 
@@ -53,27 +59,40 @@
     //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);//?
+    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);
-            led=1;
+            for(a=0;a<3;a++)leds[a]=1;
         }
         else if(num==1){
             bTouch.Draw("OFF");
             BSP_LED_Off(DISCO_LED_BLUE);
-            led=1;
+            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);            
+        }       
     }
 }
  
\ No newline at end of file