50_135_507_38_Insper
/
Menu_IHM
IHM com 4 botões e todas as telas de pontos
Fork of Menu_IHM by
teste.cpp@8:bd5509788843, 2018-05-09 (annotated)
- Committer:
- Lucarn
- Date:
- Wed May 09 16:14:38 2018 +0000
- Revision:
- 8:bd5509788843
- Parent:
- 7:a550ec99045b
- Child:
- 9:d9148b367fd9
IHM com 4 bot?es e todas as telas de pontos
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
digo1234 | 7:a550ec99045b | 1 | /* Hello World! for the TextLCD Enhanced Library*/ |
digo1234 | 7:a550ec99045b | 2 | |
digo1234 | 7:a550ec99045b | 3 | #include "mbed.h" |
digo1234 | 7:a550ec99045b | 4 | #include "TextLCD.h" |
digo1234 | 7:a550ec99045b | 5 | #define apertado 0 |
digo1234 | 7:a550ec99045b | 6 | #define solto 1 |
digo1234 | 7:a550ec99045b | 7 | |
digo1234 | 7:a550ec99045b | 8 | //#include "TextLCDScroll.h" |
digo1234 | 7:a550ec99045b | 9 | |
Lucarn | 8:bd5509788843 | 10 | DigitalIn button1(D5); |
Lucarn | 8:bd5509788843 | 11 | DigitalIn button2(D4); |
Lucarn | 8:bd5509788843 | 12 | DigitalIn button3(D6); |
Lucarn | 8:bd5509788843 | 13 | DigitalIn button4(D7); |
digo1234 | 7:a550ec99045b | 14 | |
digo1234 | 7:a550ec99045b | 15 | DigitalOut led(LED2); |
digo1234 | 7:a550ec99045b | 16 | |
digo1234 | 7:a550ec99045b | 17 | // Host PC Communication channels |
digo1234 | 7:a550ec99045b | 18 | Serial pc(USBTX, USBRX); // tx, rx |
digo1234 | 7:a550ec99045b | 19 | |
digo1234 | 7:a550ec99045b | 20 | // I2C Communication |
digo1234 | 7:a550ec99045b | 21 | I2C i2c_lcd(D14,D15); // SDA, SCL |
digo1234 | 7:a550ec99045b | 22 | |
digo1234 | 7:a550ec99045b | 23 | |
digo1234 | 7:a550ec99045b | 24 | TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type |
digo1234 | 7:a550ec99045b | 25 | |
digo1234 | 7:a550ec99045b | 26 | bool previous1=0, previous2=0; |
digo1234 | 7:a550ec99045b | 27 | int menu=0; |
digo1234 | 7:a550ec99045b | 28 | |
digo1234 | 7:a550ec99045b | 29 | void aumenta_menu(){ |
digo1234 | 7:a550ec99045b | 30 | menu = menu + 1; |
Lucarn | 8:bd5509788843 | 31 | //printf("menu %d \r\n",menu); |
Lucarn | 8:bd5509788843 | 32 | |
digo1234 | 7:a550ec99045b | 33 | } |
digo1234 | 7:a550ec99045b | 34 | |
digo1234 | 7:a550ec99045b | 35 | void diminui_menu() |
digo1234 | 7:a550ec99045b | 36 | { |
digo1234 | 7:a550ec99045b | 37 | menu = menu - 1; |
Lucarn | 8:bd5509788843 | 38 | // printf("menu %d \r\n",menu); |
Lucarn | 8:bd5509788843 | 39 | |
digo1234 | 7:a550ec99045b | 40 | } |
digo1234 | 7:a550ec99045b | 41 | |
digo1234 | 7:a550ec99045b | 42 | |
digo1234 | 7:a550ec99045b | 43 | int main() { |
digo1234 | 7:a550ec99045b | 44 | |
Lucarn | 8:bd5509788843 | 45 | //button1.fall(&aumenta_menu); |
Lucarn | 8:bd5509788843 | 46 | //button2.fall(&diminui_menu); |
digo1234 | 7:a550ec99045b | 47 | |
digo1234 | 7:a550ec99045b | 48 | lcd.setBacklight(TextLCD::LightOn); |
digo1234 | 7:a550ec99045b | 49 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
digo1234 | 7:a550ec99045b | 50 | |
digo1234 | 7:a550ec99045b | 51 | while(1){ |
digo1234 | 7:a550ec99045b | 52 | |
Lucarn | 8:bd5509788843 | 53 | if (menu<0){ |
Lucarn | 8:bd5509788843 | 54 | menu=0; |
Lucarn | 8:bd5509788843 | 55 | printf("menu %d \r\n",menu); |
Lucarn | 8:bd5509788843 | 56 | } |
Lucarn | 8:bd5509788843 | 57 | if (menu>6){ |
Lucarn | 8:bd5509788843 | 58 | menu=6; |
Lucarn | 8:bd5509788843 | 59 | printf("menu %d \r\n",menu); |
Lucarn | 8:bd5509788843 | 60 | } |
Lucarn | 8:bd5509788843 | 61 | |
Lucarn | 8:bd5509788843 | 62 | while ((menu==0)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 63 | lcd.setAddress(3,0); |
Lucarn | 8:bd5509788843 | 64 | lcd.printf("MENU PRINCIPAL"); |
Lucarn | 8:bd5509788843 | 65 | //lcd.setAddress(0,1); |
Lucarn | 8:bd5509788843 | 66 | //lcd.printf("SELECIONE UMA FUNCAO "); |
digo1234 | 7:a550ec99045b | 67 | lcd.setAddress(0,2); |
digo1234 | 7:a550ec99045b | 68 | lcd.printf("1-SALVAR PONTOS"); |
digo1234 | 7:a550ec99045b | 69 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 70 | lcd.printf("2-INICIAR PROGRAMA"); |
Lucarn | 8:bd5509788843 | 71 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 72 | {menu+=1;} |
Lucarn | 8:bd5509788843 | 73 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 74 | {menu-=1;} |
Lucarn | 8:bd5509788843 | 75 | /* if(button3==apertado) |
Lucarn | 8:bd5509788843 | 76 | {menu=0;} |
Lucarn | 8:bd5509788843 | 77 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 78 | {menu=0;}*/ |
digo1234 | 7:a550ec99045b | 79 | } |
digo1234 | 7:a550ec99045b | 80 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 81 | while ((menu==1)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 82 | //lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 83 | //lcd.printf("SELECIONE O PONTO 1"); // Ponto 1 |
digo1234 | 7:a550ec99045b | 84 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 8:bd5509788843 | 85 | lcd.setAddress(0,1); |
Lucarn | 8:bd5509788843 | 86 | lcd.printf("1-SALVAR PONTO 1"); |
digo1234 | 7:a550ec99045b | 87 | lcd.setAddress(0,2); |
Lucarn | 8:bd5509788843 | 88 | lcd.printf("2-VOLTAR"); |
digo1234 | 7:a550ec99045b | 89 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 90 | lcd.printf("3-CANCELAR OPERACAO"); |
Lucarn | 8:bd5509788843 | 91 | // previous1 = 1; |
digo1234 | 7:a550ec99045b | 92 | printf("dentro do menu1\r\n"); |
Lucarn | 8:bd5509788843 | 93 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 94 | {menu+=1;} |
Lucarn | 8:bd5509788843 | 95 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 96 | {menu-=1;} |
Lucarn | 8:bd5509788843 | 97 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 98 | {menu=0;} |
Lucarn | 8:bd5509788843 | 99 | /* if(button4==apertado) |
Lucarn | 8:bd5509788843 | 100 | {menu=1;}*/ |
Lucarn | 8:bd5509788843 | 101 | } |
Lucarn | 8:bd5509788843 | 102 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 103 | while ((menu==2)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 104 | //lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 105 | //lcd.printf("SELECIONE O PONTO 2"); // Ponto 2 |
Lucarn | 8:bd5509788843 | 106 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 8:bd5509788843 | 107 | lcd.setAddress(0,1); |
Lucarn | 8:bd5509788843 | 108 | lcd.printf("1-SALVAR PONTO 2"); |
Lucarn | 8:bd5509788843 | 109 | lcd.setAddress(0,2); |
Lucarn | 8:bd5509788843 | 110 | lcd.printf("2-VOLTAR"); |
Lucarn | 8:bd5509788843 | 111 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 112 | lcd.printf("3-CANCELAR OPERACAO"); |
Lucarn | 8:bd5509788843 | 113 | // previous1 = 1; |
Lucarn | 8:bd5509788843 | 114 | printf("dentro do menu2\r\n"); |
Lucarn | 8:bd5509788843 | 115 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 116 | {menu+=1;} |
Lucarn | 8:bd5509788843 | 117 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 118 | {menu-=1;} |
Lucarn | 8:bd5509788843 | 119 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 120 | {menu=1;} |
Lucarn | 8:bd5509788843 | 121 | // if(button4==apertado) |
Lucarn | 8:bd5509788843 | 122 | //{menu=0;} |
digo1234 | 7:a550ec99045b | 123 | } |
digo1234 | 7:a550ec99045b | 124 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 125 | while ((menu==3)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 126 | // lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 127 | //lcd.printf("SELECIONE O PONTO 3"); // Ponto 3 |
Lucarn | 8:bd5509788843 | 128 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
digo1234 | 7:a550ec99045b | 129 | lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 130 | lcd.printf("1-SALVAR PONTO 3"); |
Lucarn | 8:bd5509788843 | 131 | lcd.setAddress(0,1); |
Lucarn | 8:bd5509788843 | 132 | lcd.printf("2-voltar"); |
digo1234 | 7:a550ec99045b | 133 | lcd.setAddress(0,2); |
Lucarn | 8:bd5509788843 | 134 | lcd.printf("3-CANCELAR OPERACAO"); |
digo1234 | 7:a550ec99045b | 135 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 136 | lcd.printf("4-CONCLUIR"); |
Lucarn | 8:bd5509788843 | 137 | //previous1 = 1; |
Lucarn | 8:bd5509788843 | 138 | printf("dentro do menu3\r\n"); |
Lucarn | 8:bd5509788843 | 139 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 140 | {menu+=1;} |
Lucarn | 8:bd5509788843 | 141 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 142 | {menu-=1;} |
Lucarn | 8:bd5509788843 | 143 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 144 | {menu=0;} |
Lucarn | 8:bd5509788843 | 145 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 146 | {menu=6;} |
digo1234 | 7:a550ec99045b | 147 | } |
digo1234 | 7:a550ec99045b | 148 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 149 | while ((menu==4)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 150 | // lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 151 | //lcd.printf("SELECIONE O PONTO 3"); // Ponto 3 |
Lucarn | 8:bd5509788843 | 152 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 8:bd5509788843 | 153 | lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 154 | lcd.printf("1-SALVAR PONTO 4"); |
Lucarn | 8:bd5509788843 | 155 | lcd.setAddress(0,1); |
Lucarn | 8:bd5509788843 | 156 | lcd.printf("2-voltar"); |
Lucarn | 8:bd5509788843 | 157 | lcd.setAddress(0,2); |
Lucarn | 8:bd5509788843 | 158 | lcd.printf("3-CANCELAR OPERACAO"); |
Lucarn | 8:bd5509788843 | 159 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 160 | lcd.printf("4-CONCLUIR"); |
Lucarn | 8:bd5509788843 | 161 | //previous1 = 1; |
Lucarn | 8:bd5509788843 | 162 | printf("dentro do menu3\r\n"); |
Lucarn | 8:bd5509788843 | 163 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 164 | {menu+=1;} |
Lucarn | 8:bd5509788843 | 165 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 166 | {menu-=1;} |
Lucarn | 8:bd5509788843 | 167 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 168 | {menu=0;} |
Lucarn | 8:bd5509788843 | 169 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 170 | {menu=6;} |
Lucarn | 8:bd5509788843 | 171 | } |
Lucarn | 8:bd5509788843 | 172 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 173 | while ((menu==5)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 174 | // lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 175 | //lcd.printf("SELECIONE O PONTO 3"); // Ponto 3 |
Lucarn | 8:bd5509788843 | 176 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 8:bd5509788843 | 177 | lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 178 | lcd.printf("1-SALVAR PONTO 5"); |
Lucarn | 8:bd5509788843 | 179 | lcd.setAddress(0,1); |
Lucarn | 8:bd5509788843 | 180 | lcd.printf("2-voltar"); |
Lucarn | 8:bd5509788843 | 181 | lcd.setAddress(0,2); |
Lucarn | 8:bd5509788843 | 182 | lcd.printf("3-CANCELAR OPERACAO"); |
Lucarn | 8:bd5509788843 | 183 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 184 | lcd.printf("4-CONCLUIR"); |
Lucarn | 8:bd5509788843 | 185 | //previous1 = 1; |
Lucarn | 8:bd5509788843 | 186 | printf("dentro do menu3\r\n"); |
Lucarn | 8:bd5509788843 | 187 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 188 | {menu+=1;} |
Lucarn | 8:bd5509788843 | 189 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 190 | {menu-=1;} |
Lucarn | 8:bd5509788843 | 191 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 192 | {menu=0;} |
Lucarn | 8:bd5509788843 | 193 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 194 | {menu=6;} |
Lucarn | 8:bd5509788843 | 195 | } |
Lucarn | 8:bd5509788843 | 196 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 197 | while ((menu==6)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 198 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 8:bd5509788843 | 199 | lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 200 | lcd.printf("Pontos salvos!"); |
Lucarn | 8:bd5509788843 | 201 | lcd.setAddress(0,2); |
Lucarn | 8:bd5509788843 | 202 | lcd.printf("1-Voltar ao menu"); |
Lucarn | 8:bd5509788843 | 203 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 204 | lcd.printf("2-ressalvar pontos"); |
Lucarn | 8:bd5509788843 | 205 | printf("dentro do menu4\r\n"); |
Lucarn | 8:bd5509788843 | 206 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 207 | {menu=0;} |
Lucarn | 8:bd5509788843 | 208 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 209 | {menu=1;} |
Lucarn | 8:bd5509788843 | 210 | } |
Lucarn | 8:bd5509788843 | 211 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 212 | |
digo1234 | 7:a550ec99045b | 213 | } |
digo1234 | 7:a550ec99045b | 214 | } |
Lucarn | 8:bd5509788843 | 215 |