Menu para a IHM

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Revision:
6:49a35089f51b
Parent:
5:9936706721a8
diff -r 9936706721a8 -r 49a35089f51b main.cpp
--- a/main.cpp	Mon May 07 17:58:59 2018 +0000
+++ b/main.cpp	Mon May 07 20:56:41 2018 +0000
@@ -3,8 +3,8 @@
 #include "mbed.h"
 #include "TextLCD.h"
 //#include "TextLCDScroll.h"
-InterruptIn button1(D5);
-InterruptIn button2(D4);
+DigitalIn button1(D5);
+DigitalIn button2(D4);
 
 DigitalOut led(LED2);
  
@@ -17,81 +17,65 @@
 
 TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4);                  // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type
 
-bool flag_sim=0, flag_nao=0; 
-bool flag_sele=0, flag_cancel=0;
+bool saida=0;
 
- void sim()
-    {
-        flag_sim=1;
-    }
- void nao()
-    {
-        flag_nao=1;
-    }
- void sele()
-     {
-        flag_sele=1   ;
-      }
-  void cancel()
-    { 
-        flag_cancel=1   ;
-     } 
+
 int main() {   
 
     lcd.setBacklight(TextLCD::LightOn);
     lcd.setCursor(TextLCD::CurOff_BlkOn);
  
-    lcd.setAddress(0,0);
-    lcd.printf("Selecionar ponto? ");
-    lcd.setAddress(0,1);
-    lcd.printf("1-Sim");
-    lcd.setAddress(7,1);
-    lcd.printf("2-Nao");
-    
-    button1.fall(&sim);
-    button2.fall(&nao);
-        
-    while(1)
-    {
-        
-        if(flag_sim==1)
-        {
-            lcd.cls();
+ 
+  while(1){
+        while (button1==1 and button2==1){
+            saida=0;
             lcd.setAddress(0,0);
-            lcd.printf("selecione o ponto");
-            lcd.setCursor(TextLCD::CurOff_BlkOff);
-            printf("selecione o ponto\r\n");
-            /* button1.fall(&sele);
-             button2.fall(&cancel);                    
-                if (flag_sele==1)
-                {
-                    lcd.cls();
-                    lcd.setAddress(0,0);           
-                    lcd.printf("Mais algum ponto?");
-                    lcd.setAddress(2,1);
-                    lcd.printf("1-Sim");
-                    lcd.setAddress(2,7);
-                    lcd.printf("2-Nao");
-                    flag_sele=0;
-                    }*/
-            flag_sim=0;
-            
-        }
-        
-        if(flag_nao==1)
-        {
-            lcd.cls();
-            lcd.setAddress(0,0);
-            lcd.printf("operacao cancelada") ;
-            printf("operacao cancelada\r\n");
-            flag_nao=0; 
-        }
-        
-        led=!led;
-        wait(0.1);
+            lcd.printf("SELECIONAR PONTO? ");
+            lcd.setAddress(0,2);
+            lcd.printf("1-SIM");
+            lcd.setAddress(0,3);
+            lcd.printf("2-NAO");
+            }
+            if (button1==0){
+                lcd.cls();
+                while(1){
+                    lcd.setAddress(0,0);
+                    lcd.printf("SELECIONE O PONTO 1");
+                    lcd.setCursor(TextLCD::CurOff_BlkOff);
+                    lcd.setAddress(0,2);
+                    lcd.printf("1-PROXIMO PONTO");
+                    lcd.setAddress(0,3);
+                    lcd.printf("2-VOLTAR");
+                    if (button1==0){
+                        lcd.cls();
+                        while(1){
+                            lcd.setAddress(0,0);
+                            lcd.printf("SELECIONE O PONTO 2");
+                            lcd.setCursor(TextLCD::CurOff_BlkOff);
+                            lcd.setAddress(0,2);
+                            lcd.printf("1-PROXIMO PONTO");
+                        }
+                        
+                    }
+                    if (button2==0){
+                        lcd.cls();
+                        saida = 1;
+                        break;
+                    }
+                }
+            }
+            if (button2==0 and saida==0){
+                lcd.cls();
+                while(1){
+                    lcd.setAddress(5,1);
+                    lcd.printf("OPERACAO");
+                    lcd.setCursor(TextLCD::CurOff_BlkOff);
+                    lcd.setAddress(5,2);
+                    lcd.printf("CANCELADA");
+                    
+                }
+            }
     }
-    
-}
+}             
 
 
-