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@11:0cc3113c9ca8, 2018-05-15 (annotated)
- Committer:
- Lucarn
- Date:
- Tue May 15 17:21:18 2018 +0000
- Revision:
- 11:0cc3113c9ca8
- Parent:
- 10:1c4ab7bc50b7
- Child:
- 12:ccf601fd7e49
ihm tela aguarde
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
digo1234 | 7:a550ec99045b | 1 | |
digo1234 | 7:a550ec99045b | 2 | #include "mbed.h" |
digo1234 | 7:a550ec99045b | 3 | #include "TextLCD.h" |
digo1234 | 7:a550ec99045b | 4 | #define apertado 0 |
digo1234 | 7:a550ec99045b | 5 | #define solto 1 |
Lucarn | 10:1c4ab7bc50b7 | 6 | |
Lucarn | 10:1c4ab7bc50b7 | 7 | |
Lucarn | 8:bd5509788843 | 8 | DigitalIn button1(D5); |
Lucarn | 8:bd5509788843 | 9 | DigitalIn button2(D4); |
Lucarn | 8:bd5509788843 | 10 | DigitalIn button3(D6); |
Lucarn | 8:bd5509788843 | 11 | DigitalIn button4(D7); |
Lucarn | 10:1c4ab7bc50b7 | 12 | |
digo1234 | 7:a550ec99045b | 13 | DigitalOut led(LED2); |
digo1234 | 7:a550ec99045b | 14 | |
digo1234 | 7:a550ec99045b | 15 | // Host PC Communication channels |
digo1234 | 7:a550ec99045b | 16 | Serial pc(USBTX, USBRX); // tx, rx |
digo1234 | 7:a550ec99045b | 17 | |
digo1234 | 7:a550ec99045b | 18 | // I2C Communication |
digo1234 | 7:a550ec99045b | 19 | I2C i2c_lcd(D14,D15); // SDA, SCL |
Lucarn | 10:1c4ab7bc50b7 | 20 | |
Lucarn | 10:1c4ab7bc50b7 | 21 | |
digo1234 | 7:a550ec99045b | 22 | TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type |
Lucarn | 10:1c4ab7bc50b7 | 23 | |
digo1234 | 7:a550ec99045b | 24 | int menu=0; |
Lucarn | 9:d9148b367fd9 | 25 | float x=420.69, y=420.69, z=420.69; |
digo1234 | 7:a550ec99045b | 26 | |
digo1234 | 7:a550ec99045b | 27 | |
digo1234 | 7:a550ec99045b | 28 | int main() { |
digo1234 | 7:a550ec99045b | 29 | |
digo1234 | 7:a550ec99045b | 30 | lcd.setBacklight(TextLCD::LightOn); |
digo1234 | 7:a550ec99045b | 31 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
digo1234 | 7:a550ec99045b | 32 | |
digo1234 | 7:a550ec99045b | 33 | while(1){ |
digo1234 | 7:a550ec99045b | 34 | |
Lucarn | 8:bd5509788843 | 35 | if (menu<0){ |
Lucarn | 8:bd5509788843 | 36 | menu=0; |
Lucarn | 8:bd5509788843 | 37 | printf("menu %d \r\n",menu); |
Lucarn | 8:bd5509788843 | 38 | } |
Lucarn | 11:0cc3113c9ca8 | 39 | /*if (menu>){ |
Lucarn | 8:bd5509788843 | 40 | menu=6; |
Lucarn | 8:bd5509788843 | 41 | printf("menu %d \r\n",menu); |
Lucarn | 11:0cc3113c9ca8 | 42 | }*/ |
Lucarn | 8:bd5509788843 | 43 | |
Lucarn | 8:bd5509788843 | 44 | while ((menu==0)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 45 | lcd.setAddress(3,0); |
Lucarn | 8:bd5509788843 | 46 | lcd.printf("MENU PRINCIPAL"); |
digo1234 | 7:a550ec99045b | 47 | lcd.setAddress(0,2); |
digo1234 | 7:a550ec99045b | 48 | lcd.printf("1-SALVAR PONTOS"); |
digo1234 | 7:a550ec99045b | 49 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 50 | lcd.printf("2-INICIAR PROGRAMA"); |
Lucarn | 8:bd5509788843 | 51 | if(button1==apertado) |
Lucarn | 11:0cc3113c9ca8 | 52 | {menu=1;} |
Lucarn | 8:bd5509788843 | 53 | if(button2==apertado) |
Lucarn | 11:0cc3113c9ca8 | 54 | {menu=7;} |
Lucarn | 8:bd5509788843 | 55 | /* if(button3==apertado) |
Lucarn | 8:bd5509788843 | 56 | {menu=0;} |
Lucarn | 8:bd5509788843 | 57 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 58 | {menu=0;}*/ |
digo1234 | 7:a550ec99045b | 59 | } |
digo1234 | 7:a550ec99045b | 60 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 61 | while ((menu==1)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 62 | //lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 63 | //lcd.printf("SELECIONE O PONTO 1"); // Ponto 1 |
digo1234 | 7:a550ec99045b | 64 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 9:d9148b367fd9 | 65 | lcd.setAddress(0,0); |
Lucarn | 9:d9148b367fd9 | 66 | lcd.printf("1-SALVAR PONTO 1"); |
Lucarn | 8:bd5509788843 | 67 | lcd.setAddress(0,1); |
Lucarn | 9:d9148b367fd9 | 68 | lcd.printf("2-VOLTAR"); |
digo1234 | 7:a550ec99045b | 69 | lcd.setAddress(0,2); |
Lucarn | 9:d9148b367fd9 | 70 | lcd.printf("3-CANCELAR "); |
Lucarn | 9:d9148b367fd9 | 71 | lcd.setAddress(11,1); |
Lucarn | 9:d9148b367fd9 | 72 | lcd.printf("X:%.2f",x); |
Lucarn | 9:d9148b367fd9 | 73 | lcd.setAddress(11,2); |
Lucarn | 9:d9148b367fd9 | 74 | lcd.printf("Y:%.2f",y); |
Lucarn | 9:d9148b367fd9 | 75 | lcd.setAddress(11,3); |
Lucarn | 9:d9148b367fd9 | 76 | lcd.printf("Z:%.2f",z); |
Lucarn | 8:bd5509788843 | 77 | // previous1 = 1; |
digo1234 | 7:a550ec99045b | 78 | printf("dentro do menu1\r\n"); |
Lucarn | 8:bd5509788843 | 79 | if(button1==apertado) |
Lucarn | 11:0cc3113c9ca8 | 80 | {menu=2;} |
Lucarn | 8:bd5509788843 | 81 | if(button2==apertado) |
Lucarn | 11:0cc3113c9ca8 | 82 | {menu=0;} |
Lucarn | 8:bd5509788843 | 83 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 84 | {menu=0;} |
Lucarn | 8:bd5509788843 | 85 | /* if(button4==apertado) |
Lucarn | 8:bd5509788843 | 86 | {menu=1;}*/ |
Lucarn | 8:bd5509788843 | 87 | } |
Lucarn | 8:bd5509788843 | 88 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 89 | while ((menu==2)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 90 | //lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 91 | //lcd.printf("SELECIONE O PONTO 2"); // Ponto 2 |
Lucarn | 9:d9148b367fd9 | 92 | //x=x+0.42; |
Lucarn | 9:d9148b367fd9 | 93 | //y=y+0.17; |
Lucarn | 9:d9148b367fd9 | 94 | //z=z+0.21; |
Lucarn | 8:bd5509788843 | 95 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 9:d9148b367fd9 | 96 | lcd.setAddress(0,0); |
Lucarn | 9:d9148b367fd9 | 97 | lcd.printf("1-SALVAR PONTO 2"); |
Lucarn | 8:bd5509788843 | 98 | lcd.setAddress(0,1); |
Lucarn | 9:d9148b367fd9 | 99 | lcd.printf("2-VOLTAR"); |
Lucarn | 8:bd5509788843 | 100 | lcd.setAddress(0,2); |
Lucarn | 9:d9148b367fd9 | 101 | lcd.printf("3-CANCELAR"); |
Lucarn | 8:bd5509788843 | 102 | lcd.setAddress(0,3); |
Lucarn | 9:d9148b367fd9 | 103 | lcd.printf("4-CONCLUIR"); |
Lucarn | 9:d9148b367fd9 | 104 | lcd.setAddress(11,1); |
Lucarn | 9:d9148b367fd9 | 105 | lcd.printf("X:%.2f",x); |
Lucarn | 9:d9148b367fd9 | 106 | lcd.setAddress(11,2); |
Lucarn | 9:d9148b367fd9 | 107 | lcd.printf("Y:%.2f",y); |
Lucarn | 9:d9148b367fd9 | 108 | lcd.setAddress(11,3); |
Lucarn | 9:d9148b367fd9 | 109 | lcd.printf("Z:%.2f",z); |
Lucarn | 8:bd5509788843 | 110 | // previous1 = 1; |
Lucarn | 8:bd5509788843 | 111 | printf("dentro do menu2\r\n"); |
Lucarn | 8:bd5509788843 | 112 | if(button1==apertado) |
Lucarn | 11:0cc3113c9ca8 | 113 | {menu=3;} |
Lucarn | 8:bd5509788843 | 114 | if(button2==apertado) |
Lucarn | 11:0cc3113c9ca8 | 115 | {menu=1;} |
Lucarn | 8:bd5509788843 | 116 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 117 | {menu=1;} |
Lucarn | 10:1c4ab7bc50b7 | 118 | if(button4==apertado) |
Lucarn | 10:1c4ab7bc50b7 | 119 | {menu=6;} |
digo1234 | 7:a550ec99045b | 120 | } |
digo1234 | 7:a550ec99045b | 121 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 122 | while ((menu==3)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 123 | // lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 124 | //lcd.printf("SELECIONE O PONTO 3"); // Ponto 3 |
Lucarn | 9:d9148b367fd9 | 125 | //x=x+0.42; |
Lucarn | 9:d9148b367fd9 | 126 | //y=y+0.17; |
Lucarn | 9:d9148b367fd9 | 127 | //z=z+0.21; |
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 | 9:d9148b367fd9 | 132 | lcd.printf("2-VOLTAR"); |
digo1234 | 7:a550ec99045b | 133 | lcd.setAddress(0,2); |
Lucarn | 9:d9148b367fd9 | 134 | lcd.printf("3-CANCELAR"); |
digo1234 | 7:a550ec99045b | 135 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 136 | lcd.printf("4-CONCLUIR"); |
Lucarn | 9:d9148b367fd9 | 137 | lcd.setAddress(11,1); |
Lucarn | 9:d9148b367fd9 | 138 | lcd.printf("X:%.2f",x); |
Lucarn | 9:d9148b367fd9 | 139 | lcd.setAddress(11,2); |
Lucarn | 9:d9148b367fd9 | 140 | lcd.printf("Y:%.2f",y); |
Lucarn | 9:d9148b367fd9 | 141 | lcd.setAddress(11,3); |
Lucarn | 9:d9148b367fd9 | 142 | lcd.printf("Z:%.2f",z); |
Lucarn | 8:bd5509788843 | 143 | //previous1 = 1; |
Lucarn | 8:bd5509788843 | 144 | printf("dentro do menu3\r\n"); |
Lucarn | 8:bd5509788843 | 145 | if(button1==apertado) |
Lucarn | 11:0cc3113c9ca8 | 146 | {menu=4;} |
Lucarn | 8:bd5509788843 | 147 | if(button2==apertado) |
Lucarn | 11:0cc3113c9ca8 | 148 | {menu=2;} |
Lucarn | 8:bd5509788843 | 149 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 150 | {menu=0;} |
Lucarn | 8:bd5509788843 | 151 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 152 | {menu=6;} |
digo1234 | 7:a550ec99045b | 153 | } |
digo1234 | 7:a550ec99045b | 154 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 155 | while ((menu==4)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 156 | // lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 157 | //lcd.printf("SELECIONE O PONTO 3"); // Ponto 3 |
Lucarn | 8:bd5509788843 | 158 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 8:bd5509788843 | 159 | lcd.setAddress(0,0); |
Lucarn | 11:0cc3113c9ca8 | 160 | lcd.printf("1-SALVAR PONTO 4"); |
Lucarn | 8:bd5509788843 | 161 | lcd.setAddress(0,1); |
Lucarn | 9:d9148b367fd9 | 162 | lcd.printf("2-VOLTAR"); |
Lucarn | 8:bd5509788843 | 163 | lcd.setAddress(0,2); |
Lucarn | 9:d9148b367fd9 | 164 | lcd.printf("3-CANCELAR"); |
Lucarn | 8:bd5509788843 | 165 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 166 | lcd.printf("4-CONCLUIR"); |
Lucarn | 9:d9148b367fd9 | 167 | lcd.setAddress(11,1); |
Lucarn | 9:d9148b367fd9 | 168 | lcd.printf("X:%.2f",x); |
Lucarn | 9:d9148b367fd9 | 169 | lcd.setAddress(11,2); |
Lucarn | 9:d9148b367fd9 | 170 | lcd.printf("Y:%.2f",y); |
Lucarn | 9:d9148b367fd9 | 171 | lcd.setAddress(11,3); |
Lucarn | 9:d9148b367fd9 | 172 | lcd.printf("Z:%.2f",z); |
Lucarn | 8:bd5509788843 | 173 | //previous1 = 1; |
Lucarn | 8:bd5509788843 | 174 | printf("dentro do menu3\r\n"); |
Lucarn | 8:bd5509788843 | 175 | if(button1==apertado) |
Lucarn | 11:0cc3113c9ca8 | 176 | {menu=5;} |
Lucarn | 8:bd5509788843 | 177 | if(button2==apertado) |
Lucarn | 11:0cc3113c9ca8 | 178 | {menu=3;} |
Lucarn | 8:bd5509788843 | 179 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 180 | {menu=0;} |
Lucarn | 8:bd5509788843 | 181 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 182 | {menu=6;} |
Lucarn | 8:bd5509788843 | 183 | } |
Lucarn | 8:bd5509788843 | 184 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 185 | while ((menu==5)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 186 | // lcd.setAddress(0,0); |
Lucarn | 8:bd5509788843 | 187 | //lcd.printf("SELECIONE O PONTO 3"); // Ponto 3 |
Lucarn | 8:bd5509788843 | 188 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 8:bd5509788843 | 189 | lcd.setAddress(0,0); |
Lucarn | 11:0cc3113c9ca8 | 190 | lcd.printf("1-SALVAR PONTO 5"); |
Lucarn | 8:bd5509788843 | 191 | lcd.setAddress(0,1); |
Lucarn | 9:d9148b367fd9 | 192 | lcd.printf("2-VOLTAR"); |
Lucarn | 8:bd5509788843 | 193 | lcd.setAddress(0,2); |
Lucarn | 9:d9148b367fd9 | 194 | lcd.printf("3-CANCELAR"); |
Lucarn | 8:bd5509788843 | 195 | lcd.setAddress(0,3); |
Lucarn | 8:bd5509788843 | 196 | lcd.printf("4-CONCLUIR"); |
Lucarn | 9:d9148b367fd9 | 197 | lcd.setAddress(11,1); |
Lucarn | 9:d9148b367fd9 | 198 | lcd.printf("X:%.2f",x); |
Lucarn | 9:d9148b367fd9 | 199 | lcd.setAddress(11,2); |
Lucarn | 9:d9148b367fd9 | 200 | lcd.printf("Y:%.2f",y); |
Lucarn | 9:d9148b367fd9 | 201 | lcd.setAddress(11,3); |
Lucarn | 9:d9148b367fd9 | 202 | lcd.printf("Z:%.2f",z); |
Lucarn | 8:bd5509788843 | 203 | //previous1 = 1; |
Lucarn | 8:bd5509788843 | 204 | printf("dentro do menu3\r\n"); |
Lucarn | 8:bd5509788843 | 205 | if(button1==apertado) |
Lucarn | 11:0cc3113c9ca8 | 206 | {menu=6;} |
Lucarn | 8:bd5509788843 | 207 | if(button2==apertado) |
Lucarn | 11:0cc3113c9ca8 | 208 | {menu=4;} |
Lucarn | 8:bd5509788843 | 209 | if(button3==apertado) |
Lucarn | 8:bd5509788843 | 210 | {menu=0;} |
Lucarn | 8:bd5509788843 | 211 | if(button4==apertado) |
Lucarn | 8:bd5509788843 | 212 | {menu=6;} |
Lucarn | 8:bd5509788843 | 213 | } |
Lucarn | 8:bd5509788843 | 214 | lcd.cls(); |
Lucarn | 8:bd5509788843 | 215 | while ((menu==6)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 8:bd5509788843 | 216 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 9:d9148b367fd9 | 217 | lcd.setAddress(3,0); |
Lucarn | 9:d9148b367fd9 | 218 | lcd.printf("PONTOS SALVOS!"); |
Lucarn | 8:bd5509788843 | 219 | lcd.setAddress(0,2); |
Lucarn | 9:d9148b367fd9 | 220 | lcd.printf("1-VOLTAR AO MENU"); |
Lucarn | 8:bd5509788843 | 221 | lcd.setAddress(0,3); |
Lucarn | 9:d9148b367fd9 | 222 | lcd.printf("2-RESSALVAR PONTOS"); |
Lucarn | 8:bd5509788843 | 223 | printf("dentro do menu4\r\n"); |
Lucarn | 8:bd5509788843 | 224 | if(button1==apertado) |
Lucarn | 8:bd5509788843 | 225 | {menu=0;} |
Lucarn | 8:bd5509788843 | 226 | if(button2==apertado) |
Lucarn | 8:bd5509788843 | 227 | {menu=1;} |
Lucarn | 8:bd5509788843 | 228 | } |
Lucarn | 8:bd5509788843 | 229 | lcd.cls(); |
Lucarn | 11:0cc3113c9ca8 | 230 | if ((menu==7)&& (button1==solto) && (button2==solto) && (button3==solto) && (button4==solto)){ |
Lucarn | 11:0cc3113c9ca8 | 231 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
Lucarn | 11:0cc3113c9ca8 | 232 | lcd.setAddress(0,0); |
Lucarn | 11:0cc3113c9ca8 | 233 | lcd.printf("RODANDO PROGRAMA!"); |
Lucarn | 11:0cc3113c9ca8 | 234 | lcd.setAddress(0,2); |
Lucarn | 11:0cc3113c9ca8 | 235 | lcd.printf("Aguarde..."); |
Lucarn | 11:0cc3113c9ca8 | 236 | printf("dentro do menurodando programa\r\n"); |
Lucarn | 11:0cc3113c9ca8 | 237 | wait(5); |
Lucarn | 11:0cc3113c9ca8 | 238 | menu=0; |
Lucarn | 11:0cc3113c9ca8 | 239 | } |
Lucarn | 11:0cc3113c9ca8 | 240 | lcd.cls(); |
Lucarn | 11:0cc3113c9ca8 | 241 | |
Lucarn | 8:bd5509788843 | 242 | |
digo1234 | 7:a550ec99045b | 243 | } |
digo1234 | 7:a550ec99045b | 244 | } |
Lucarn | 10:1c4ab7bc50b7 | 245 |