Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
main.cpp@11:6b7accf18fe2, 2018-05-11 (annotated)
- Committer:
- claraluques
- Date:
- Fri May 11 13:08:29 2018 +0000
- Revision:
- 11:6b7accf18fe2
- Parent:
- 10:97002056ecda
- Child:
- 12:64ed645e79ad
tentando compartilhar no resposit?rio
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
claraluques | 11:6b7accf18fe2 | 1 | /*CÓDIGO PARA LCD MENU HELLEN - GRUPO T*/ |
claraluques | 11:6b7accf18fe2 | 2 | |
wim | 0:a75049de1a82 | 3 | #include "mbed.h" |
wim | 0:a75049de1a82 | 4 | #include "TextLCD.h" |
claraluques | 11:6b7accf18fe2 | 5 | |
claraluques | 5:30f5ffe0ea0b | 6 | // Host PC Communication channels |
claraluques | 11:6b7accf18fe2 | 7 | Serial pc(USBTX, USBRX); // tx, rx //não apagar |
wim | 4:a3e4bb2053cb | 8 | |
claraluques | 5:30f5ffe0ea0b | 9 | //I2C Communication |
claraluques | 11:6b7accf18fe2 | 10 | I2C i2c_lcd(D14,D15); // SDA, SCL //não apagar |
claraluques | 5:30f5ffe0ea0b | 11 | |
claraluques | 5:30f5ffe0ea0b | 12 | //Botão push |
claraluques | 5:30f5ffe0ea0b | 13 | InterruptIn botao_enter(D13); |
claraluques | 5:30f5ffe0ea0b | 14 | InterruptIn botao_cima(D10); |
claraluques | 5:30f5ffe0ea0b | 15 | InterruptIn botao_baixo(D9); |
claraluques | 5:30f5ffe0ea0b | 16 | |
claraluques | 5:30f5ffe0ea0b | 17 | //LCD instantiation |
claraluques | 11:6b7accf18fe2 | 18 | TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); //não apagar |
claraluques | 5:30f5ffe0ea0b | 19 | |
claraluques | 5:30f5ffe0ea0b | 20 | //variáveis int |
claraluques | 5:30f5ffe0ea0b | 21 | int bot_enter; |
claraluques | 5:30f5ffe0ea0b | 22 | int bot_cima; |
claraluques | 5:30f5ffe0ea0b | 23 | int bot_baixo; |
claraluques | 6:24cbbdf2dac2 | 24 | int penter = 0; |
claraluques | 6:24cbbdf2dac2 | 25 | int pcima = 0; |
claraluques | 6:24cbbdf2dac2 | 26 | int pbaixo = 0; |
claraluques | 9:86b5a317fcd4 | 27 | int cola; |
claraluques | 9:86b5a317fcd4 | 28 | int exec; |
wim | 0:a75049de1a82 | 29 | |
claraluques | 5:30f5ffe0ea0b | 30 | //variáveis float |
claraluques | 7:e2c1b0338286 | 31 | float cx = 120.458; |
claraluques | 7:e2c1b0338286 | 32 | float cy = 457.854; |
claraluques | 7:e2c1b0338286 | 33 | float cz = 782.659; |
claraluques | 8:b80f50544ddd | 34 | float cx_salva; |
claraluques | 8:b80f50544ddd | 35 | float cy_salva; |
claraluques | 8:b80f50544ddd | 36 | float cz_salva; |
claraluques | 5:30f5ffe0ea0b | 37 | |
claraluques | 5:30f5ffe0ea0b | 38 | //funções interrupt |
claraluques | 5:30f5ffe0ea0b | 39 | void botenter_press(void); |
claraluques | 5:30f5ffe0ea0b | 40 | void botenter_solto(void); |
wim | 0:a75049de1a82 | 41 | |
claraluques | 5:30f5ffe0ea0b | 42 | void botcima_press(void); |
claraluques | 5:30f5ffe0ea0b | 43 | void botcima_solto(void); |
claraluques | 5:30f5ffe0ea0b | 44 | |
claraluques | 5:30f5ffe0ea0b | 45 | void botbaixo_press(void); |
claraluques | 5:30f5ffe0ea0b | 46 | void botbaixo_solto(void); |
claraluques | 5:30f5ffe0ea0b | 47 | |
claraluques | 11:6b7accf18fe2 | 48 | //criar classe "menu" (funções para as telas) |
claraluques | 5:30f5ffe0ea0b | 49 | class Menu{ |
claraluques | 5:30f5ffe0ea0b | 50 | public: |
claraluques | 5:30f5ffe0ea0b | 51 | int linha; |
claraluques | 5:30f5ffe0ea0b | 52 | int func; |
wim | 4:a3e4bb2053cb | 53 | |
claraluques | 6:24cbbdf2dac2 | 54 | void movercursor(int min, int max, int col){ //função para mover cursor de seleção |
claraluques | 5:30f5ffe0ea0b | 55 | linha = min; |
claraluques | 7:e2c1b0338286 | 56 | lcd.locate(col,min); |
claraluques | 7:e2c1b0338286 | 57 | lcd.printf("%c", 0x3E); |
claraluques | 6:24cbbdf2dac2 | 58 | while (bot_enter==penter){ |
claraluques | 5:30f5ffe0ea0b | 59 | if (bot_cima==1){ |
claraluques | 5:30f5ffe0ea0b | 60 | if (linha==min){ |
claraluques | 6:24cbbdf2dac2 | 61 | lcd.locate(col,min); |
claraluques | 6:24cbbdf2dac2 | 62 | lcd.printf(" "); |
claraluques | 5:30f5ffe0ea0b | 63 | linha=max; |
claraluques | 6:24cbbdf2dac2 | 64 | lcd.locate(col, linha); |
claraluques | 6:24cbbdf2dac2 | 65 | lcd.printf("%c", 0x3E); |
claraluques | 5:30f5ffe0ea0b | 66 | } |
claraluques | 5:30f5ffe0ea0b | 67 | else { |
claraluques | 6:24cbbdf2dac2 | 68 | lcd.locate(col,linha); |
claraluques | 6:24cbbdf2dac2 | 69 | lcd.printf(" "); |
claraluques | 5:30f5ffe0ea0b | 70 | linha--; |
claraluques | 6:24cbbdf2dac2 | 71 | lcd.locate(col, linha); |
claraluques | 6:24cbbdf2dac2 | 72 | lcd.printf("%c", 0x3E); |
claraluques | 5:30f5ffe0ea0b | 73 | } |
claraluques | 6:24cbbdf2dac2 | 74 | bot_cima = 0; |
claraluques | 5:30f5ffe0ea0b | 75 | } |
claraluques | 5:30f5ffe0ea0b | 76 | if (bot_baixo==1){ |
claraluques | 5:30f5ffe0ea0b | 77 | if (linha==max){ |
claraluques | 6:24cbbdf2dac2 | 78 | lcd.locate(col,max); |
claraluques | 6:24cbbdf2dac2 | 79 | lcd.printf(" "); |
claraluques | 5:30f5ffe0ea0b | 80 | linha=min; |
claraluques | 6:24cbbdf2dac2 | 81 | lcd.locate(col, linha); |
claraluques | 6:24cbbdf2dac2 | 82 | lcd.printf("%c", 0x3E); |
claraluques | 5:30f5ffe0ea0b | 83 | } |
claraluques | 5:30f5ffe0ea0b | 84 | else { |
claraluques | 6:24cbbdf2dac2 | 85 | lcd.locate(col,linha); |
claraluques | 6:24cbbdf2dac2 | 86 | lcd.printf(" "); |
claraluques | 5:30f5ffe0ea0b | 87 | linha++; |
claraluques | 6:24cbbdf2dac2 | 88 | lcd.locate(col, linha); |
claraluques | 6:24cbbdf2dac2 | 89 | lcd.printf("%c", 0x3E); |
claraluques | 5:30f5ffe0ea0b | 90 | } |
claraluques | 6:24cbbdf2dac2 | 91 | bot_baixo = 0; |
claraluques | 5:30f5ffe0ea0b | 92 | } |
claraluques | 11:6b7accf18fe2 | 93 | } |
claraluques | 5:30f5ffe0ea0b | 94 | } |
claraluques | 5:30f5ffe0ea0b | 95 | |
claraluques | 5:30f5ffe0ea0b | 96 | //func 0 |
claraluques | 5:30f5ffe0ea0b | 97 | void inicializar(){ //função tela incial de boas-vindas |
claraluques | 5:30f5ffe0ea0b | 98 | lcd.cls(); |
claraluques | 8:b80f50544ddd | 99 | lcd.locate(4,0); |
claraluques | 8:b80f50544ddd | 100 | lcd.printf("Bem-vindo(a)"); |
claraluques | 5:30f5ffe0ea0b | 101 | lcd.locate(0,1); |
claraluques | 8:b80f50544ddd | 102 | lcd.printf("Utilize seu EPI para operar a maquina."); |
claraluques | 9:86b5a317fcd4 | 103 | wait(1); |
claraluques | 5:30f5ffe0ea0b | 104 | func = 1; |
claraluques | 5:30f5ffe0ea0b | 105 | } |
claraluques | 5:30f5ffe0ea0b | 106 | |
claraluques | 5:30f5ffe0ea0b | 107 | //func 1 |
claraluques | 5:30f5ffe0ea0b | 108 | void menuprincipal(){ //função menu principal |
claraluques | 9:86b5a317fcd4 | 109 | bot_enter = 0; |
claraluques | 5:30f5ffe0ea0b | 110 | lcd.cls(); |
claraluques | 5:30f5ffe0ea0b | 111 | lcd.locate(1,0); |
claraluques | 5:30f5ffe0ea0b | 112 | lcd.printf("Modo JOG"); |
claraluques | 5:30f5ffe0ea0b | 113 | lcd.locate(1,1); |
claraluques | 5:30f5ffe0ea0b | 114 | lcd.printf("Modo Automatico"); |
claraluques | 5:30f5ffe0ea0b | 115 | lcd.locate(1,2); |
claraluques | 5:30f5ffe0ea0b | 116 | lcd.printf("Config"); |
claraluques | 9:86b5a317fcd4 | 117 | lcd.locate(1,3); |
claraluques | 9:86b5a317fcd4 | 118 | lcd.printf("Zerar"); |
claraluques | 9:86b5a317fcd4 | 119 | movercursor(0,3,0); |
claraluques | 6:24cbbdf2dac2 | 120 | if (bot_enter!=penter){ |
claraluques | 5:30f5ffe0ea0b | 121 | if (linha==0){ |
claraluques | 5:30f5ffe0ea0b | 122 | func = 2; |
claraluques | 5:30f5ffe0ea0b | 123 | } |
claraluques | 5:30f5ffe0ea0b | 124 | else if (linha==1) { |
claraluques | 5:30f5ffe0ea0b | 125 | func = 3; |
claraluques | 5:30f5ffe0ea0b | 126 | } |
claraluques | 5:30f5ffe0ea0b | 127 | else if (linha==2) { |
claraluques | 5:30f5ffe0ea0b | 128 | func = 4; |
claraluques | 5:30f5ffe0ea0b | 129 | } |
claraluques | 9:86b5a317fcd4 | 130 | else if (linha==3) { |
claraluques | 9:86b5a317fcd4 | 131 | func = 8; |
claraluques | 9:86b5a317fcd4 | 132 | } |
claraluques | 5:30f5ffe0ea0b | 133 | } |
claraluques | 5:30f5ffe0ea0b | 134 | } |
claraluques | 6:24cbbdf2dac2 | 135 | |
claraluques | 6:24cbbdf2dac2 | 136 | //func 2 |
claraluques | 6:24cbbdf2dac2 | 137 | void jog(){ //função tela jog |
claraluques | 9:86b5a317fcd4 | 138 | bot_enter = 0; |
claraluques | 6:24cbbdf2dac2 | 139 | lcd.cls(); |
claraluques | 7:e2c1b0338286 | 140 | lcd.locate(4,0); |
claraluques | 7:e2c1b0338286 | 141 | lcd.printf("Coordenadas:"); |
claraluques | 7:e2c1b0338286 | 142 | lcd.locate(0,1); |
claraluques | 7:e2c1b0338286 | 143 | lcd.printf("X:%.3f", cx); |
claraluques | 7:e2c1b0338286 | 144 | lcd.locate(0,2); |
claraluques | 7:e2c1b0338286 | 145 | lcd.printf("Y:%.3f", cy); |
claraluques | 7:e2c1b0338286 | 146 | lcd.locate(0,3); |
claraluques | 7:e2c1b0338286 | 147 | lcd.printf("Z:%.3f", cz); |
claraluques | 6:24cbbdf2dac2 | 148 | lcd.locate(11,1); |
claraluques | 6:24cbbdf2dac2 | 149 | lcd.printf("Salvar"); |
claraluques | 6:24cbbdf2dac2 | 150 | lcd.locate(11,2); |
claraluques | 6:24cbbdf2dac2 | 151 | lcd.printf("Concluir"); |
claraluques | 6:24cbbdf2dac2 | 152 | lcd.locate(11,3); |
claraluques | 6:24cbbdf2dac2 | 153 | lcd.printf("Cancelar"); |
claraluques | 7:e2c1b0338286 | 154 | movercursor(1,3,10); |
claraluques | 6:24cbbdf2dac2 | 155 | if (bot_enter!=penter){ |
claraluques | 6:24cbbdf2dac2 | 156 | if (linha==1){ |
claraluques | 6:24cbbdf2dac2 | 157 | func = 5; |
claraluques | 8:b80f50544ddd | 158 | cx_salva = cx; |
claraluques | 8:b80f50544ddd | 159 | cy_salva = cy; |
claraluques | 8:b80f50544ddd | 160 | cz_salva = cz; |
claraluques | 6:24cbbdf2dac2 | 161 | } |
claraluques | 6:24cbbdf2dac2 | 162 | else if (linha==2) { |
claraluques | 8:b80f50544ddd | 163 | func = 7; |
claraluques | 6:24cbbdf2dac2 | 164 | } |
claraluques | 6:24cbbdf2dac2 | 165 | else if (linha==3) { |
claraluques | 8:b80f50544ddd | 166 | func = 1; |
claraluques | 6:24cbbdf2dac2 | 167 | } |
claraluques | 6:24cbbdf2dac2 | 168 | } |
claraluques | 6:24cbbdf2dac2 | 169 | } |
claraluques | 6:24cbbdf2dac2 | 170 | |
claraluques | 9:86b5a317fcd4 | 171 | //func 3 |
claraluques | 9:86b5a317fcd4 | 172 | |
claraluques | 9:86b5a317fcd4 | 173 | //func 4 |
claraluques | 9:86b5a317fcd4 | 174 | |
claraluques | 8:b80f50544ddd | 175 | //func 5 |
claraluques | 9:86b5a317fcd4 | 176 | void telasalvamento(){ //função para quando salvar um ponto |
claraluques | 8:b80f50544ddd | 177 | lcd.cls(); |
claraluques | 8:b80f50544ddd | 178 | lcd.locate(0,0); |
claraluques | 8:b80f50544ddd | 179 | lcd.printf("Voce salvou o ponto:"); |
claraluques | 9:86b5a317fcd4 | 180 | lcd.locate(5,1); |
claraluques | 9:86b5a317fcd4 | 181 | lcd.printf("X: %.3f", cx_salva); |
claraluques | 9:86b5a317fcd4 | 182 | lcd.locate(5,2); |
claraluques | 9:86b5a317fcd4 | 183 | lcd.printf("Y: %.3f", cy_salva); |
claraluques | 9:86b5a317fcd4 | 184 | lcd.locate(5,3); |
claraluques | 9:86b5a317fcd4 | 185 | lcd.printf("Z: %.3f", cz_salva); |
claraluques | 9:86b5a317fcd4 | 186 | wait(1); |
claraluques | 8:b80f50544ddd | 187 | func = 6; |
claraluques | 8:b80f50544ddd | 188 | } |
claraluques | 8:b80f50544ddd | 189 | |
claraluques | 9:86b5a317fcd4 | 190 | //func 6 |
claraluques | 9:86b5a317fcd4 | 191 | void telacola(){ //tela para escolher o tipo de sequencia da cola |
claraluques | 9:86b5a317fcd4 | 192 | lcd.cls(); |
claraluques | 9:86b5a317fcd4 | 193 | bot_enter = 0; |
claraluques | 9:86b5a317fcd4 | 194 | lcd.printf("P/ o proximo ponto:"); |
claraluques | 9:86b5a317fcd4 | 195 | lcd.locate(3,1); |
claraluques | 9:86b5a317fcd4 | 196 | lcd.printf("Sem cola"); |
claraluques | 9:86b5a317fcd4 | 197 | lcd.locate(3,2); |
claraluques | 9:86b5a317fcd4 | 198 | lcd.printf("Cola no ponto"); |
claraluques | 9:86b5a317fcd4 | 199 | lcd.locate(3,3); |
claraluques | 9:86b5a317fcd4 | 200 | lcd.printf("Cola continua"); |
claraluques | 9:86b5a317fcd4 | 201 | movercursor(1,3,2); |
claraluques | 9:86b5a317fcd4 | 202 | if (bot_enter!=penter){ |
claraluques | 9:86b5a317fcd4 | 203 | if (linha==1){ |
claraluques | 9:86b5a317fcd4 | 204 | cola = 0; |
claraluques | 9:86b5a317fcd4 | 205 | func = 2; |
claraluques | 9:86b5a317fcd4 | 206 | } |
claraluques | 9:86b5a317fcd4 | 207 | else if (linha==2) { |
claraluques | 9:86b5a317fcd4 | 208 | cola = 1; |
claraluques | 9:86b5a317fcd4 | 209 | func = 2; |
claraluques | 9:86b5a317fcd4 | 210 | } |
claraluques | 9:86b5a317fcd4 | 211 | else if (linha==3) { |
claraluques | 9:86b5a317fcd4 | 212 | cola = 2; |
claraluques | 9:86b5a317fcd4 | 213 | func = 2; |
claraluques | 9:86b5a317fcd4 | 214 | } |
claraluques | 9:86b5a317fcd4 | 215 | } |
claraluques | 9:86b5a317fcd4 | 216 | } |
claraluques | 9:86b5a317fcd4 | 217 | |
claraluques | 9:86b5a317fcd4 | 218 | //func 7 |
claraluques | 9:86b5a317fcd4 | 219 | void executarprograma() { //tela para selecionar se deseja executar o programa |
claraluques | 9:86b5a317fcd4 | 220 | lcd.cls(); |
claraluques | 9:86b5a317fcd4 | 221 | bot_enter = 0; |
claraluques | 9:86b5a317fcd4 | 222 | lcd.locate(2,0); |
claraluques | 9:86b5a317fcd4 | 223 | lcd.printf("VOCE CONCLUIU SEU"); |
claraluques | 9:86b5a317fcd4 | 224 | lcd.locate(5,1); |
claraluques | 9:86b5a317fcd4 | 225 | lcd.printf("PROGRAMA."); |
claraluques | 9:86b5a317fcd4 | 226 | lcd.locate(0,2); |
claraluques | 9:86b5a317fcd4 | 227 | lcd.printf("Deseja"); |
claraluques | 9:86b5a317fcd4 | 228 | lcd.locate(0,3); |
claraluques | 9:86b5a317fcd4 | 229 | lcd.printf("executa-lo?"); |
claraluques | 9:86b5a317fcd4 | 230 | lcd.locate(14,2); |
claraluques | 9:86b5a317fcd4 | 231 | lcd.printf("Sim"); |
claraluques | 9:86b5a317fcd4 | 232 | lcd.locate(14,3); |
claraluques | 9:86b5a317fcd4 | 233 | lcd.printf("Voltar"); |
claraluques | 9:86b5a317fcd4 | 234 | movercursor(2,3,13); |
claraluques | 9:86b5a317fcd4 | 235 | if (bot_enter!=penter) { |
claraluques | 9:86b5a317fcd4 | 236 | if (linha==2){ |
claraluques | 9:86b5a317fcd4 | 237 | exec = 1; |
claraluques | 9:86b5a317fcd4 | 238 | func = 9; |
claraluques | 9:86b5a317fcd4 | 239 | } |
claraluques | 9:86b5a317fcd4 | 240 | else if (linha==3){ |
claraluques | 9:86b5a317fcd4 | 241 | exec = 0; |
claraluques | 9:86b5a317fcd4 | 242 | func = 2; |
claraluques | 9:86b5a317fcd4 | 243 | } |
claraluques | 9:86b5a317fcd4 | 244 | } |
claraluques | 9:86b5a317fcd4 | 245 | } |
claraluques | 9:86b5a317fcd4 | 246 | |
claraluques | 9:86b5a317fcd4 | 247 | //func 8 |
claraluques | 9:86b5a317fcd4 | 248 | void telazerar(){ //tela para zerar a máquina |
claraluques | 9:86b5a317fcd4 | 249 | lcd.cls(); |
claraluques | 9:86b5a317fcd4 | 250 | bot_enter = 0; |
claraluques | 9:86b5a317fcd4 | 251 | lcd.locate(2,0); |
claraluques | 9:86b5a317fcd4 | 252 | lcd.printf("Pressione OK para zerar as coordenadas"); |
claraluques | 9:86b5a317fcd4 | 253 | lcd.locate(7,2); |
claraluques | 9:86b5a317fcd4 | 254 | lcd.printf("OK"); |
claraluques | 9:86b5a317fcd4 | 255 | lcd.locate(7,3); |
claraluques | 9:86b5a317fcd4 | 256 | lcd.printf("Voltar"); |
claraluques | 9:86b5a317fcd4 | 257 | movercursor(2,3,6); |
claraluques | 9:86b5a317fcd4 | 258 | if (bot_enter!=penter) { |
claraluques | 9:86b5a317fcd4 | 259 | if (linha==2){ |
claraluques | 9:86b5a317fcd4 | 260 | cx = 0; |
claraluques | 9:86b5a317fcd4 | 261 | cy = 0; |
claraluques | 9:86b5a317fcd4 | 262 | cz = 0; |
claraluques | 9:86b5a317fcd4 | 263 | func = 10; |
claraluques | 9:86b5a317fcd4 | 264 | } |
claraluques | 9:86b5a317fcd4 | 265 | else if (linha==3){ |
claraluques | 9:86b5a317fcd4 | 266 | func = 1; |
claraluques | 9:86b5a317fcd4 | 267 | } |
claraluques | 9:86b5a317fcd4 | 268 | } |
claraluques | 9:86b5a317fcd4 | 269 | } |
claraluques | 9:86b5a317fcd4 | 270 | |
claraluques | 9:86b5a317fcd4 | 271 | //func 9 |
claraluques | 9:86b5a317fcd4 | 272 | void executando(){ //tela de executando |
claraluques | 9:86b5a317fcd4 | 273 | lcd.cls(); |
claraluques | 9:86b5a317fcd4 | 274 | lcd.locate(4,1); |
claraluques | 9:86b5a317fcd4 | 275 | lcd.printf("Executando"); |
claraluques | 9:86b5a317fcd4 | 276 | int contador = 0; |
claraluques | 9:86b5a317fcd4 | 277 | while (exec==1){ |
claraluques | 9:86b5a317fcd4 | 278 | lcd.locate(14,1); |
claraluques | 9:86b5a317fcd4 | 279 | lcd.printf(". "); |
claraluques | 9:86b5a317fcd4 | 280 | wait(0.5); |
claraluques | 9:86b5a317fcd4 | 281 | lcd.locate(14,1); |
claraluques | 9:86b5a317fcd4 | 282 | lcd.printf(".. "); |
claraluques | 9:86b5a317fcd4 | 283 | wait(0.5); |
claraluques | 9:86b5a317fcd4 | 284 | lcd.locate(14,1); |
claraluques | 9:86b5a317fcd4 | 285 | lcd.printf("..."); |
claraluques | 9:86b5a317fcd4 | 286 | wait(0.5); |
claraluques | 9:86b5a317fcd4 | 287 | lcd.locate(14,1); |
claraluques | 9:86b5a317fcd4 | 288 | lcd.printf(" "); |
claraluques | 9:86b5a317fcd4 | 289 | wait(0.5); |
claraluques | 9:86b5a317fcd4 | 290 | contador++; |
claraluques | 9:86b5a317fcd4 | 291 | if (contador>=2){ |
claraluques | 9:86b5a317fcd4 | 292 | exec = 0; |
claraluques | 9:86b5a317fcd4 | 293 | func = 11; |
claraluques | 9:86b5a317fcd4 | 294 | } |
claraluques | 9:86b5a317fcd4 | 295 | } |
claraluques | 9:86b5a317fcd4 | 296 | } |
claraluques | 9:86b5a317fcd4 | 297 | |
claraluques | 9:86b5a317fcd4 | 298 | //func 10 |
claraluques | 9:86b5a317fcd4 | 299 | void zerado() { //tela avisando que a máquina foi zerada |
claraluques | 9:86b5a317fcd4 | 300 | lcd.cls(); |
claraluques | 9:86b5a317fcd4 | 301 | lcd.locate(5,1); |
claraluques | 9:86b5a317fcd4 | 302 | lcd.printf("Voce zerou"); |
claraluques | 9:86b5a317fcd4 | 303 | lcd.locate(5,2); |
claraluques | 9:86b5a317fcd4 | 304 | lcd.printf("a maquina!"); |
claraluques | 9:86b5a317fcd4 | 305 | wait(1); |
claraluques | 9:86b5a317fcd4 | 306 | func = 8; |
claraluques | 9:86b5a317fcd4 | 307 | } |
claraluques | 9:86b5a317fcd4 | 308 | |
claraluques | 9:86b5a317fcd4 | 309 | //func 11 |
claraluques | 9:86b5a317fcd4 | 310 | void finalizado() { |
claraluques | 9:86b5a317fcd4 | 311 | lcd.cls(); |
claraluques | 9:86b5a317fcd4 | 312 | lcd.locate(6,1); |
claraluques | 9:86b5a317fcd4 | 313 | lcd.printf("PROGRAMA"); |
claraluques | 9:86b5a317fcd4 | 314 | lcd.locate(5,2); |
claraluques | 9:86b5a317fcd4 | 315 | lcd.printf("FINALIZADO"); |
claraluques | 9:86b5a317fcd4 | 316 | wait(1); |
claraluques | 9:86b5a317fcd4 | 317 | func = 1; |
claraluques | 9:86b5a317fcd4 | 318 | } |
claraluques | 9:86b5a317fcd4 | 319 | |
claraluques | 9:86b5a317fcd4 | 320 | Menu(); //não apagar |
claraluques | 5:30f5ffe0ea0b | 321 | }; |
wim | 1:ef419b21167d | 322 | |
claraluques | 9:86b5a317fcd4 | 323 | Menu::Menu(){ //não apagar |
claraluques | 10:97002056ecda | 324 | func = 0 |
claraluques | 9:86b5a317fcd4 | 325 | } |
wim | 3:f238b4f7874f | 326 | |
claraluques | 5:30f5ffe0ea0b | 327 | Menu menu; |
wim | 3:f238b4f7874f | 328 | |
claraluques | 5:30f5ffe0ea0b | 329 | int main () { |
claraluques | 5:30f5ffe0ea0b | 330 | lcd.setBacklight(TextLCD::LightOn); //liga backlight |
claraluques | 9:86b5a317fcd4 | 331 | lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor |
claraluques | 5:30f5ffe0ea0b | 332 | |
claraluques | 9:86b5a317fcd4 | 333 | botao_enter.rise(&botenter_press); //chama função botao enter |
claraluques | 9:86b5a317fcd4 | 334 | botao_cima.rise(&botcima_press); //chama função botao para cima |
claraluques | 9:86b5a317fcd4 | 335 | botao_baixo.rise(&botbaixo_press); //chama função bota para baixo |
claraluques | 6:24cbbdf2dac2 | 336 | |
claraluques | 5:30f5ffe0ea0b | 337 | while(1){ |
claraluques | 9:86b5a317fcd4 | 338 | switch(menu.func){ //faz com que as telas sejam iniciadas |
claraluques | 5:30f5ffe0ea0b | 339 | case 0: menu.inicializar(); break; |
claraluques | 5:30f5ffe0ea0b | 340 | case 1: menu.menuprincipal(); break; |
claraluques | 6:24cbbdf2dac2 | 341 | case 2: menu.jog(); break; |
claraluques | 9:86b5a317fcd4 | 342 | //case 3: menu.automatico(); break; |
claraluques | 9:86b5a317fcd4 | 343 | //case 4: menu.config(); break; |
claraluques | 9:86b5a317fcd4 | 344 | case 5: menu.telasalvamento(); break; |
claraluques | 9:86b5a317fcd4 | 345 | case 6: menu.telacola(); break; |
claraluques | 9:86b5a317fcd4 | 346 | case 7: menu.executarprograma(); break; |
claraluques | 9:86b5a317fcd4 | 347 | case 8: menu.telazerar(); break; |
claraluques | 9:86b5a317fcd4 | 348 | case 9: menu.executando(); break; |
claraluques | 9:86b5a317fcd4 | 349 | case 10: menu.zerado(); break; |
claraluques | 9:86b5a317fcd4 | 350 | case 11: menu.finalizado(); break; |
claraluques | 9:86b5a317fcd4 | 351 | |
claraluques | 5:30f5ffe0ea0b | 352 | } |
claraluques | 5:30f5ffe0ea0b | 353 | } |
claraluques | 11:6b7accf18fe2 | 354 | } |
claraluques | 5:30f5ffe0ea0b | 355 | |
claraluques | 11:6b7accf18fe2 | 356 | //função interrupt botão enter |
claraluques | 11:6b7accf18fe2 | 357 | void botenter_press(void){ |
claraluques | 11:6b7accf18fe2 | 358 | penter = bot_enter; |
claraluques | 11:6b7accf18fe2 | 359 | bot_enter = !bot_enter; |
claraluques | 11:6b7accf18fe2 | 360 | printf("enter high"); |
claraluques | 11:6b7accf18fe2 | 361 | } |
claraluques | 9:86b5a317fcd4 | 362 | |
claraluques | 11:6b7accf18fe2 | 363 | //função interrupt botão cima |
claraluques | 11:6b7accf18fe2 | 364 | void botcima_press(void){ |
claraluques | 11:6b7accf18fe2 | 365 | pcima = bot_cima; |
claraluques | 11:6b7accf18fe2 | 366 | bot_cima = !bot_cima; |
claraluques | 11:6b7accf18fe2 | 367 | printf("cima high"); |
claraluques | 11:6b7accf18fe2 | 368 | } |
wim | 0:a75049de1a82 | 369 | |
claraluques | 5:30f5ffe0ea0b | 370 | //função interrupt botão baixo |
claraluques | 11:6b7accf18fe2 | 371 | void botbaixo_press(void){ |
claraluques | 11:6b7accf18fe2 | 372 | pbaixo = bot_baixo; |
claraluques | 11:6b7accf18fe2 | 373 | bot_baixo = !bot_baixo; |
claraluques | 11:6b7accf18fe2 | 374 | printf("baixo high"); |
claraluques | 11:6b7accf18fe2 | 375 | } |