Pecunia_Insper / Mbed 2 deprecated Main

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003  
00004 // Host PC Communication channels
00005 Serial pc(USBTX, USBRX); // tx, rx
00006  
00007 // I2C Communication
00008 I2C i2c_lcd(D14,D15); // SDA, SCL
00009 
00010   
00011 TextLCD_I2C lcd(&i2c_lcd, 0x7F, TextLCD::LCD20x4);  // I2C bus, PCF8574 Slaveaddress, LCD Type
00012 
00013 //DigitalIn mybutton(USER_BUTTON); // definindo o user button
00014 DigitalIn bot_1(D4);
00015 DigitalIn bot_2(D5);
00016 DigitalIn bot_3(D6);
00017 DigitalIn bot_4(D7);
00018 
00019 int x=0;
00020 int p=0;
00021 int main() { 
00022 // Luz
00023     lcd.setCursor(TextLCD::CurOff_BlkOn);
00024     lcd.setBacklight(TextLCD::LightOn);
00025  
00026 //lcd.setAddress(5,2);
00027 //lcd.printf("salve");
00028 //wait_ms(2000);
00029 //lcd.cls();
00030 //lcd.setAddress(5,2);
00031 //lcd.printf("...");
00032 //wait_ms(2000); 
00033 //lcd.cls();
00034 //lcd.setAddress(5,2);
00035 //lcd.printf("seu otario");
00036 //printf("nmero: %d \n", a);
00037 //while (a < 10)
00038     //{lcd.setAddress(a,0);
00039     //lcd.printf("%d \n", a);
00040     //a=a+1;
00041     //wait_ms(1000);
00042     //}
00043     //return 0;
00044 while (true)  { 
00045 if (x == 0 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00046     {
00047      lcd.setAddress(0,0);
00048      lcd.printf("Selec. pontos (1)       ");
00049      lcd.setAddress(0,1);
00050      lcd.printf("Testar tarefa (2)    ");
00051      lcd.setAddress(0,2);
00052      lcd.printf("Realizar tarefa (3)     ");
00053      lcd.setAddress(0,3);
00054      lcd.printf("                            ");
00055      if (bot_1 == 0 )
00056     {
00057      x=1;
00058     }
00059     if (bot_2 == 0 )
00060     {
00061      x=2;
00062     }
00063     if (bot_3 == 0 )
00064     {
00065      x=3;
00066     }
00067     }
00068 if (x ==1 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00069     {
00070      lcd.setAddress(0,0);
00071      lcd.printf("Gravar ponto 1 (1)            ");
00072      lcd.setAddress(0,1);
00073      lcd.printf("Cancelar (2)              ");
00074      lcd.setAddress(0,2);
00075      lcd.printf("                            ");
00076      lcd.setAddress(0,3);
00077      lcd.printf("                            ");
00078      if (bot_1 == 0 )
00079      {
00080      x=4;
00081      }
00082      if (bot_2 == 0 )
00083      {
00084      x=0;
00085     }
00086     }
00087 if (x ==2 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00088     {
00089      lcd.cls();
00090      wait(0.2);
00091      lcd.setAddress(0,0);
00092      lcd.printf("                            ");
00093      lcd.setAddress(p,1);
00094      lcd.printf("     TESTANDO                    ");
00095      lcd.setAddress(0,2);
00096      lcd.printf("      PONTOS              ");
00097      lcd.setAddress(0,3);
00098      lcd.printf("                            ");
00099      wait(0.5);
00100     }
00101 if (x ==3 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00102     {
00103      lcd.cls();
00104      wait(0.2);
00105      lcd.setAddress(0,0);
00106      lcd.printf("                            ");
00107      lcd.setAddress(0,1);
00108      lcd.printf("    REALIZANDO           ");
00109      lcd.setAddress(0,2);
00110      lcd.printf("       COLAGEM               ");
00111      lcd.setAddress(0,3);
00112      lcd.printf("                            ");
00113      wait(0.5);
00114     }
00115 if (x == 4 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00116     {
00117      lcd.setAddress(0,0);
00118      lcd.printf("Selec. ponto 2 (1)       ");
00119      lcd.setAddress(0,1);
00120      lcd.printf("Reescolher P1 (2)    ");
00121      lcd.setAddress(0,2);
00122      lcd.printf("Cancelar (3)     ");
00123      lcd.setAddress(0,3);
00124      lcd.printf("Concluir (4)                  ");
00125      if (bot_1 == 0 )
00126     {
00127      x=5;
00128     }
00129     if (bot_2 == 0 )
00130     {
00131      x=1;
00132     }
00133     if (bot_3 == 0 )
00134     {
00135      x=0;
00136      }
00137     if (bot_4 == 0 )
00138     {
00139      x=0;
00140     }
00141     }
00142     
00143 if (x == 5 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00144     {
00145      lcd.setAddress(0,0);
00146      lcd.printf("Selec. ponto 3 (1)       ");
00147      lcd.setAddress(0,1);
00148      lcd.printf("Reescolher P2 (2)    ");
00149      lcd.setAddress(0,2);
00150      lcd.printf("Cancelar (3)     ");
00151      lcd.setAddress(0,3);
00152      lcd.printf("Concluir (4)                  ");
00153      if (bot_1 == 0 )
00154     {
00155      x=6;
00156     }
00157     if (bot_2 == 0 )
00158     {
00159      x=1;
00160     }
00161     if (bot_3 == 0 )
00162     {
00163      x=0;
00164      }
00165     if (bot_4 == 0 )
00166     {
00167      x=0;
00168     }
00169     }
00170     
00171 if (x == 6 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00172     {
00173      lcd.setAddress(0,0);
00174      lcd.printf("Selec. ponto 4 (1)       ");
00175      lcd.setAddress(0,1);     
00176      lcd.printf("Reescolher P3 (2)          ");
00177      lcd.setAddress(0,2);
00178      lcd.printf("Cancelar (3)          ");
00179      lcd.setAddress(0,3);
00180      lcd.printf("Concluir (4)                  ");
00181      if (bot_1 == 0 )
00182     {
00183      x=7;
00184     }
00185     if (bot_2 == 0 )
00186     {
00187      x=5;
00188     }
00189     if (bot_3 == 0 )
00190     {
00191      x=0;
00192      }
00193     if (bot_4 == 0 )
00194     {
00195      x=0;
00196     }
00197     }
00198     
00199 if (x == 7 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00200     {
00201      lcd.setAddress(0,0);
00202      lcd.printf("Selec. ponto 5 (1)       ");
00203      lcd.setAddress(0,1);
00204      lcd.printf("Reescolher P4 (2)    ");
00205      lcd.setAddress(0,2);
00206      lcd.printf("Cancelar (3)     ");
00207      lcd.setAddress(0,3);
00208      lcd.printf("Concluir (4)                  ");
00209      if (bot_1 == 0 )
00210     {
00211      x=8;
00212     }
00213     if (bot_2 == 0 )
00214     {
00215      x=6;
00216     }
00217     if (bot_3 == 0 )
00218     {
00219      x=0;
00220      }
00221     if (bot_4 == 0 )
00222     {
00223      x=0;
00224     }
00225     }
00226 if (x == 8 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00227     {
00228      lcd.setAddress(0,0);
00229      lcd.printf("Selec. ponto 6 (1)       ");
00230      lcd.setAddress(0,1);
00231      lcd.printf("Reescolher P5 (2)    ");
00232      lcd.setAddress(0,2);
00233      lcd.printf("Cancelar (3)     ");
00234      lcd.setAddress(0,3);
00235      lcd.printf("Concluir (4)                  ");
00236      if (bot_1 == 0 )
00237     {
00238      x=9;
00239     }
00240     if (bot_2 == 0 )
00241     {
00242      x=7;
00243     }
00244     if (bot_3 == 0 )
00245     {
00246      x=0;
00247      }
00248     if (bot_4 == 0 )
00249     {
00250      x=0;
00251     }
00252     } 
00253 
00254 if (x == 9 & bot_1 == 1 & bot_2 == 1 & bot_3 == 1 & bot_4 == 1)
00255     {
00256      lcd.setAddress(0,0);
00257      lcd.printf("Reescolher P6 (1)         ");
00258      lcd.setAddress(0,1);
00259      lcd.printf("Cancelar (2)          ");
00260      lcd.setAddress(0,2);
00261      lcd.printf("Concluir (3)                 ");
00262      lcd.setAddress(0,3);
00263      lcd.printf("                           ");
00264      if (bot_1 == 0 )
00265     {
00266      x=8;
00267     }
00268     if (bot_2 == 0 )
00269     {
00270      x=0;
00271     }
00272     if (bot_3 == 0 )
00273     {
00274      x=0;
00275      }
00276 
00277     }      
00278 
00279     //if (x==1)
00280       //      {lcd.setAddress(1,1);
00281         //    lcd.cls();
00282           //  lcd.printf("estado %d \n", a);
00283       //      a=a+1;
00284         //    x=0;
00285           //  }
00286      //if (x==2|| b == 1)
00287        //     {lcd.setAddress(1,1);
00288          //   lcd.cls();
00289            // lcd.printf("troca de estado %d \n", a);
00290             //a=a+1;
00291             //b=2;
00292 
00293             //}
00294             
00295             }
00296             }