Menu para a IHM

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

main.cpp

Committer:
digo1234
Date:
2018-05-07
Revision:
5:9936706721a8
Parent:
4:a3e4bb2053cb
Child:
6:49a35089f51b

File content as of revision 5:9936706721a8:

/* Hello World! for the TextLCD Enhanced Library*/

#include "mbed.h"
#include "TextLCD.h"
//#include "TextLCDScroll.h"
InterruptIn button1(D5);
InterruptIn button2(D4);

DigitalOut led(LED2);
 
// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx
 
// I2C Communication
I2C i2c_lcd(D14,D15); // SDA, SCL


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;

 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();
            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);
    }
    
}