VEjam se o MAin funciona

Dependencies:   TextLCD mbed

main.cpp

Committer:
brunolleite
Date:
2018-05-22
Revision:
2:3cd315d7a107
Parent:
1:405e88f6e720

File content as of revision 2:3cd315d7a107:

#include "mbed.h"
#include "TextLCD.h"
 
// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx
 
// I2C Communication
I2C i2c_lcd(D14,D15); // SDA, SCL

  
TextLCD_I2C lcd(&i2c_lcd, 0x7F, TextLCD::LCD20x4);  // I2C bus, PCF8574 Slaveaddress, LCD Type

//DigitalIn mybutton(USER_BUTTON); // definindo o user button
DigitalIn bot_1(D4);
DigitalIn bot_2(D5);
DigitalIn bot_3(D6);
DigitalIn bot_4(D7);

int x=0;
int p=0;
int main() { 
// Luz
    lcd.setCursor(TextLCD::CurOff_BlkOn);
    lcd.setBacklight(TextLCD::LightOn);
 
//lcd.setAddress(5,2);
//lcd.printf("salve");
//wait_ms(2000);
//lcd.cls();
//lcd.setAddress(5,2);
//lcd.printf("...");
//wait_ms(2000); 
//lcd.cls();
//lcd.setAddress(5,2);
//lcd.printf("seu otario");
//printf("nmero: %d \n", a);
//while (a < 10)
    //{lcd.setAddress(a,0);
    //lcd.printf("%d \n", a);
    //a=a+1;
    //wait_ms(1000);
    //}
    //return 0;
while (true)  { 
if (x == 0 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Selec. pontos (1)       ");
     lcd.setAddress(0,1);
     lcd.printf("Testar tarefa (2)    ");
     lcd.setAddress(0,2);
     lcd.printf("Realizar tarefa (3)     ");
     lcd.setAddress(0,3);
     lcd.printf("                            ");
     if (bot_1 == 0 )
    {
     x=1;
    }
    if (bot_2 == 0 )
    {
     x=2;
    }
    if (bot_3 == 0 )
    {
     x=3;
    }
    }
if (x ==1 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Gravar ponto 1 (1)            ");
     lcd.setAddress(0,1);
     lcd.printf("Cancelar (2)              ");
     lcd.setAddress(0,2);
     lcd.printf("                            ");
     lcd.setAddress(0,3);
     lcd.printf("                            ");
     if (bot_1 == 0 )
     {
     x=4;
     }
     if (bot_2 == 0 )
     {
     x=0;
    }
    }
if (x ==2 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.cls();
     wait(0.2);
     lcd.setAddress(0,0);
     lcd.printf("                            ");
     lcd.setAddress(p,1);
     lcd.printf("     TESTANDO                    ");
     lcd.setAddress(0,2);
     lcd.printf("      PONTOS              ");
     lcd.setAddress(0,3);
     lcd.printf("                            ");
     wait(0.5);
    }
if (x ==3 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.cls();
     wait(0.2);
     lcd.setAddress(0,0);
     lcd.printf("                            ");
     lcd.setAddress(0,1);
     lcd.printf("    REALIZANDO           ");
     lcd.setAddress(0,2);
     lcd.printf("       COLAGEM               ");
     lcd.setAddress(0,3);
     lcd.printf("                            ");
     wait(0.5);
    }
if (x == 4 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Selec. ponto 2 (1)       ");
     lcd.setAddress(0,1);
     lcd.printf("Reescolher P1 (2)    ");
     lcd.setAddress(0,2);
     lcd.printf("Cancelar (3)     ");
     lcd.setAddress(0,3);
     lcd.printf("Concluir (4)                  ");
     if (bot_1 == 0 )
    {
     x=5;
    }
    if (bot_2 == 0 )
    {
     x=1;
    }
    if (bot_3 == 0 )
    {
     x=0;
     }
    if (bot_4 == 0 )
    {
     x=0;
    }
    }
    
if (x == 5 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Selec. ponto 3 (1)       ");
     lcd.setAddress(0,1);
     lcd.printf("Reescolher P2 (2)    ");
     lcd.setAddress(0,2);
     lcd.printf("Cancelar (3)     ");
     lcd.setAddress(0,3);
     lcd.printf("Concluir (4)                  ");
     if (bot_1 == 0 )
    {
     x=6;
    }
    if (bot_2 == 0 )
    {
     x=1;
    }
    if (bot_3 == 0 )
    {
     x=0;
     }
    if (bot_4 == 0 )
    {
     x=0;
    }
    }
    
if (x == 6 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Selec. ponto 4 (1)       ");
     lcd.setAddress(0,1);     
     lcd.printf("Reescolher P3 (2)          ");
     lcd.setAddress(0,2);
     lcd.printf("Cancelar (3)          ");
     lcd.setAddress(0,3);
     lcd.printf("Concluir (4)                  ");
     if (bot_1 == 0 )
    {
     x=7;
    }
    if (bot_2 == 0 )
    {
     x=5;
    }
    if (bot_3 == 0 )
    {
     x=0;
     }
    if (bot_4 == 0 )
    {
     x=0;
    }
    }
    
if (x == 7 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Selec. ponto 5 (1)       ");
     lcd.setAddress(0,1);
     lcd.printf("Reescolher P4 (2)    ");
     lcd.setAddress(0,2);
     lcd.printf("Cancelar (3)     ");
     lcd.setAddress(0,3);
     lcd.printf("Concluir (4)                  ");
     if (bot_1 == 0 )
    {
     x=8;
    }
    if (bot_2 == 0 )
    {
     x=6;
    }
    if (bot_3 == 0 )
    {
     x=0;
     }
    if (bot_4 == 0 )
    {
     x=0;
    }
    }
if (x == 8 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Selec. ponto 6 (1)       ");
     lcd.setAddress(0,1);
     lcd.printf("Reescolher P5 (2)    ");
     lcd.setAddress(0,2);
     lcd.printf("Cancelar (3)     ");
     lcd.setAddress(0,3);
     lcd.printf("Concluir (4)                  ");
     if (bot_1 == 0 )
    {
     x=9;
    }
    if (bot_2 == 0 )
    {
     x=7;
    }
    if (bot_3 == 0 )
    {
     x=0;
     }
    if (bot_4 == 0 )
    {
     x=0;
    }
    } 

if (x == 9 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
    {
     lcd.setAddress(0,0);
     lcd.printf("Reescolher P6 (1)         ");
     lcd.setAddress(0,1);
     lcd.printf("Cancelar (2)          ");
     lcd.setAddress(0,2);
     lcd.printf("Concluir (3)                 ");
     lcd.setAddress(0,3);
     lcd.printf("                           ");
     if (bot_1 == 0 )
    {
     x=8;
    }
    if (bot_2 == 0 )
    {
     x=0;
    }
    if (bot_3 == 0 )
    {
     x=0;
     }

    }      

    //if (x==1)
      //      {lcd.setAddress(1,1);
        //    lcd.cls();
          //  lcd.printf("estado %d \n", a);
      //      a=a+1;
        //    x=0;
          //  }
     //if (x==2|| b == 1)
       //     {lcd.setAddress(1,1);
         //   lcd.cls();
           // lcd.printf("troca de estado %d \n", a);
            //a=a+1;
            //b=2;

            //}
            
            }
            }