Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Committer:
claraluques
Date:
Tue May 15 13:07:03 2018 +0000
Revision:
19:2c890ae2d187
Parent:
18:5338b83b4de9
Child:
20:ccbd80b668ce
algumas fun??es integradas

Who changed what in which revision?

UserRevisionLine numberNew 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 19:2c890ae2d187 5 #include "string"
claraluques 19:2c890ae2d187 6 //#include "classes.h"
claraluques 11:6b7accf18fe2 7
claraluques 5:30f5ffe0ea0b 8 // Host PC Communication channels
claraluques 11:6b7accf18fe2 9 Serial pc(USBTX, USBRX); // tx, rx //não apagar
wim 4:a3e4bb2053cb 10
claraluques 5:30f5ffe0ea0b 11 //I2C Communication
claraluques 11:6b7accf18fe2 12 I2C i2c_lcd(D14,D15); // SDA, SCL //não apagar
claraluques 5:30f5ffe0ea0b 13
claraluques 5:30f5ffe0ea0b 14 //Botão push
claraluques 5:30f5ffe0ea0b 15 InterruptIn botao_enter(D13);
claraluques 5:30f5ffe0ea0b 16 InterruptIn botao_cima(D10);
claraluques 5:30f5ffe0ea0b 17 InterruptIn botao_baixo(D9);
claraluques 5:30f5ffe0ea0b 18
claraluques 5:30f5ffe0ea0b 19 //LCD instantiation
claraluques 11:6b7accf18fe2 20 TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); //não apagar
claraluques 5:30f5ffe0ea0b 21
claraluques 5:30f5ffe0ea0b 22 //variáveis int
claraluques 5:30f5ffe0ea0b 23 int bot_enter;
claraluques 5:30f5ffe0ea0b 24 int bot_cima;
claraluques 5:30f5ffe0ea0b 25 int bot_baixo;
claraluques 6:24cbbdf2dac2 26 int penter = 0;
claraluques 6:24cbbdf2dac2 27 int pcima = 0;
claraluques 6:24cbbdf2dac2 28 int pbaixo = 0;
claraluques 9:86b5a317fcd4 29 int cola;
claraluques 9:86b5a317fcd4 30 int exec;
claraluques 12:64ed645e79ad 31 int select = 0;
claraluques 15:043bb371a50b 32 int pontos = 10;
claraluques 16:6912d19a0016 33 int coords;
wim 0:a75049de1a82 34
claraluques 5:30f5ffe0ea0b 35 //variáveis float
claraluques 7:e2c1b0338286 36 float cx = 120.458;
claraluques 7:e2c1b0338286 37 float cy = 457.854;
claraluques 7:e2c1b0338286 38 float cz = 782.659;
claraluques 8:b80f50544ddd 39 float cx_salva;
claraluques 8:b80f50544ddd 40 float cy_salva;
claraluques 8:b80f50544ddd 41 float cz_salva;
claraluques 5:30f5ffe0ea0b 42
claraluques 5:30f5ffe0ea0b 43 //funções interrupt
claraluques 5:30f5ffe0ea0b 44 void botenter_press(void);
claraluques 5:30f5ffe0ea0b 45 void botenter_solto(void);
wim 0:a75049de1a82 46
claraluques 5:30f5ffe0ea0b 47 void botcima_press(void);
claraluques 5:30f5ffe0ea0b 48 void botcima_solto(void);
claraluques 5:30f5ffe0ea0b 49
claraluques 5:30f5ffe0ea0b 50 void botbaixo_press(void);
claraluques 5:30f5ffe0ea0b 51 void botbaixo_solto(void);
claraluques 5:30f5ffe0ea0b 52
claraluques 19:2c890ae2d187 53 #include "classes.h"
claraluques 19:2c890ae2d187 54
claraluques 11:6b7accf18fe2 55 //criar classe "menu" (funções para as telas)
claraluques 18:5338b83b4de9 56 /*class Menu{
claraluques 5:30f5ffe0ea0b 57 public:
claraluques 5:30f5ffe0ea0b 58 int linha;
claraluques 5:30f5ffe0ea0b 59 int func;
wim 4:a3e4bb2053cb 60
claraluques 6:24cbbdf2dac2 61 void movercursor(int min, int max, int col){ //função para mover cursor de seleção
claraluques 5:30f5ffe0ea0b 62 linha = min;
claraluques 7:e2c1b0338286 63 lcd.locate(col,min);
claraluques 7:e2c1b0338286 64 lcd.printf("%c", 0x3E);
claraluques 6:24cbbdf2dac2 65 while (bot_enter==penter){
claraluques 5:30f5ffe0ea0b 66 if (bot_cima==1){
claraluques 5:30f5ffe0ea0b 67 if (linha==min){
claraluques 6:24cbbdf2dac2 68 lcd.locate(col,min);
claraluques 6:24cbbdf2dac2 69 lcd.printf(" ");
claraluques 5:30f5ffe0ea0b 70 linha=max;
claraluques 6:24cbbdf2dac2 71 lcd.locate(col, linha);
claraluques 6:24cbbdf2dac2 72 lcd.printf("%c", 0x3E);
claraluques 5:30f5ffe0ea0b 73 }
claraluques 5:30f5ffe0ea0b 74 else {
claraluques 6:24cbbdf2dac2 75 lcd.locate(col,linha);
claraluques 6:24cbbdf2dac2 76 lcd.printf(" ");
claraluques 5:30f5ffe0ea0b 77 linha--;
claraluques 6:24cbbdf2dac2 78 lcd.locate(col, linha);
claraluques 6:24cbbdf2dac2 79 lcd.printf("%c", 0x3E);
claraluques 5:30f5ffe0ea0b 80 }
claraluques 6:24cbbdf2dac2 81 bot_cima = 0;
claraluques 5:30f5ffe0ea0b 82 }
claraluques 16:6912d19a0016 83 else if (bot_baixo==1){
claraluques 5:30f5ffe0ea0b 84 if (linha==max){
claraluques 6:24cbbdf2dac2 85 lcd.locate(col,max);
claraluques 6:24cbbdf2dac2 86 lcd.printf(" ");
claraluques 5:30f5ffe0ea0b 87 linha=min;
claraluques 6:24cbbdf2dac2 88 lcd.locate(col, linha);
claraluques 6:24cbbdf2dac2 89 lcd.printf("%c", 0x3E);
claraluques 5:30f5ffe0ea0b 90 }
claraluques 5:30f5ffe0ea0b 91 else {
claraluques 6:24cbbdf2dac2 92 lcd.locate(col,linha);
claraluques 6:24cbbdf2dac2 93 lcd.printf(" ");
claraluques 5:30f5ffe0ea0b 94 linha++;
claraluques 6:24cbbdf2dac2 95 lcd.locate(col, linha);
claraluques 6:24cbbdf2dac2 96 lcd.printf("%c", 0x3E);
claraluques 5:30f5ffe0ea0b 97 }
claraluques 6:24cbbdf2dac2 98 bot_baixo = 0;
claraluques 5:30f5ffe0ea0b 99 }
claraluques 16:6912d19a0016 100 if (func==2){
claraluques 16:6912d19a0016 101 lcd.locate(2,1);
claraluques 16:6912d19a0016 102 lcd.printf("%.3f", cx);
claraluques 16:6912d19a0016 103 lcd.locate(2,2);
claraluques 16:6912d19a0016 104 lcd.printf("%.3f", cy);
claraluques 16:6912d19a0016 105 lcd.locate(2,3);
claraluques 16:6912d19a0016 106 lcd.printf("%.3f", cz);
claraluques 16:6912d19a0016 107 }
claraluques 16:6912d19a0016 108 //cx = cx + 0.1;
claraluques 16:6912d19a0016 109 //cy = cy + 0.1;
claraluques 16:6912d19a0016 110 //cz = cz + 0.1;
claraluques 11:6b7accf18fe2 111 }
claraluques 5:30f5ffe0ea0b 112 }
claraluques 5:30f5ffe0ea0b 113
claraluques 5:30f5ffe0ea0b 114 //func 0
claraluques 5:30f5ffe0ea0b 115 void inicializar(){ //função tela incial de boas-vindas
claraluques 5:30f5ffe0ea0b 116 lcd.cls();
claraluques 8:b80f50544ddd 117 lcd.locate(4,0);
claraluques 8:b80f50544ddd 118 lcd.printf("Bem-vindo(a)");
claraluques 5:30f5ffe0ea0b 119 lcd.locate(0,1);
claraluques 8:b80f50544ddd 120 lcd.printf("Utilize seu EPI para operar a maquina.");
claraluques 9:86b5a317fcd4 121 wait(1);
claraluques 5:30f5ffe0ea0b 122 func = 1;
claraluques 5:30f5ffe0ea0b 123 }
claraluques 5:30f5ffe0ea0b 124
claraluques 5:30f5ffe0ea0b 125 //func 1
claraluques 5:30f5ffe0ea0b 126 void menuprincipal(){ //função menu principal
claraluques 9:86b5a317fcd4 127 bot_enter = 0;
claraluques 5:30f5ffe0ea0b 128 lcd.cls();
claraluques 5:30f5ffe0ea0b 129 lcd.locate(1,0);
claraluques 5:30f5ffe0ea0b 130 lcd.printf("Modo JOG");
claraluques 5:30f5ffe0ea0b 131 lcd.locate(1,1);
claraluques 5:30f5ffe0ea0b 132 lcd.printf("Modo Automatico");
claraluques 5:30f5ffe0ea0b 133 lcd.locate(1,2);
claraluques 5:30f5ffe0ea0b 134 lcd.printf("Config");
claraluques 9:86b5a317fcd4 135 lcd.locate(1,3);
claraluques 9:86b5a317fcd4 136 lcd.printf("Zerar");
claraluques 9:86b5a317fcd4 137 movercursor(0,3,0);
claraluques 6:24cbbdf2dac2 138 if (bot_enter!=penter){
claraluques 5:30f5ffe0ea0b 139 if (linha==0){
claraluques 5:30f5ffe0ea0b 140 func = 2;
claraluques 5:30f5ffe0ea0b 141 }
claraluques 5:30f5ffe0ea0b 142 else if (linha==1) {
claraluques 5:30f5ffe0ea0b 143 func = 3;
claraluques 5:30f5ffe0ea0b 144 }
claraluques 5:30f5ffe0ea0b 145 else if (linha==2) {
claraluques 5:30f5ffe0ea0b 146 func = 4;
claraluques 5:30f5ffe0ea0b 147 }
claraluques 9:86b5a317fcd4 148 else if (linha==3) {
claraluques 9:86b5a317fcd4 149 func = 8;
claraluques 9:86b5a317fcd4 150 }
claraluques 5:30f5ffe0ea0b 151 }
claraluques 5:30f5ffe0ea0b 152 }
claraluques 6:24cbbdf2dac2 153
claraluques 6:24cbbdf2dac2 154 //func 2
claraluques 6:24cbbdf2dac2 155 void jog(){ //função tela jog
claraluques 9:86b5a317fcd4 156 bot_enter = 0;
claraluques 16:6912d19a0016 157 coords = 0;
claraluques 6:24cbbdf2dac2 158 lcd.cls();
claraluques 7:e2c1b0338286 159 lcd.locate(4,0);
claraluques 7:e2c1b0338286 160 lcd.printf("Coordenadas:");
claraluques 7:e2c1b0338286 161 lcd.locate(0,1);
claraluques 16:6912d19a0016 162 lcd.printf("X:");
claraluques 7:e2c1b0338286 163 lcd.locate(0,2);
claraluques 16:6912d19a0016 164 lcd.printf("Y:");
claraluques 7:e2c1b0338286 165 lcd.locate(0,3);
claraluques 16:6912d19a0016 166 lcd.printf("Z:");
claraluques 6:24cbbdf2dac2 167 lcd.locate(11,1);
claraluques 6:24cbbdf2dac2 168 lcd.printf("Salvar");
claraluques 6:24cbbdf2dac2 169 lcd.locate(11,2);
claraluques 6:24cbbdf2dac2 170 lcd.printf("Concluir");
claraluques 6:24cbbdf2dac2 171 lcd.locate(11,3);
claraluques 16:6912d19a0016 172 lcd.printf("Cancelar");
claraluques 16:6912d19a0016 173 //while (bot_enter==penter){
claraluques 16:6912d19a0016 174 //lcd.locate(2,1);
claraluques 16:6912d19a0016 175 //lcd.printf("%.3f", cx);
claraluques 16:6912d19a0016 176 //lcd.locate(2,2);
claraluques 16:6912d19a0016 177 //lcd.printf("%.3f", cy);
claraluques 16:6912d19a0016 178 //lcd.locate(2,3);
claraluques 16:6912d19a0016 179 //lcd.printf("%.3f", cz);
claraluques 16:6912d19a0016 180 movercursor(1,3,10);
claraluques 16:6912d19a0016 181 //cx++;
claraluques 16:6912d19a0016 182 //cy++;
claraluques 16:6912d19a0016 183 //cz++;
claraluques 16:6912d19a0016 184 // }
claraluques 6:24cbbdf2dac2 185 if (bot_enter!=penter){
claraluques 16:6912d19a0016 186 coords = 1;
claraluques 13:1670c34440a5 187 if (linha==1){
claraluques 13:1670c34440a5 188 if (pontos>0){
claraluques 13:1670c34440a5 189 pontos--;
claraluques 13:1670c34440a5 190 cx_salva = cx;
claraluques 13:1670c34440a5 191 cy_salva = cy;
claraluques 13:1670c34440a5 192 cz_salva = cz;
claraluques 13:1670c34440a5 193 func = 5;
claraluques 13:1670c34440a5 194 }
claraluques 13:1670c34440a5 195 else if (pontos==0){
claraluques 13:1670c34440a5 196 func = 16;
claraluques 13:1670c34440a5 197 }
claraluques 6:24cbbdf2dac2 198 }
claraluques 6:24cbbdf2dac2 199 else if (linha==2) {
claraluques 8:b80f50544ddd 200 func = 7;
claraluques 6:24cbbdf2dac2 201 }
claraluques 6:24cbbdf2dac2 202 else if (linha==3) {
claraluques 8:b80f50544ddd 203 func = 1;
claraluques 15:043bb371a50b 204 pontos = 10;
claraluques 6:24cbbdf2dac2 205 }
claraluques 16:6912d19a0016 206 }
claraluques 6:24cbbdf2dac2 207 }
claraluques 6:24cbbdf2dac2 208
claraluques 9:86b5a317fcd4 209 //func 3
claraluques 12:64ed645e79ad 210 void automatico(){ //tela modo automatico
claraluques 12:64ed645e79ad 211 lcd.cls();
claraluques 12:64ed645e79ad 212 bot_enter = 0;
claraluques 12:64ed645e79ad 213 lcd.printf("Modo automatico");
claraluques 12:64ed645e79ad 214 lcd.locate(7,2);
claraluques 12:64ed645e79ad 215 lcd.printf("OK");
claraluques 12:64ed645e79ad 216 lcd.locate(7,3);
claraluques 12:64ed645e79ad 217 lcd.printf("Voltar");
claraluques 12:64ed645e79ad 218 movercursor(2,3,6);
claraluques 12:64ed645e79ad 219 if (bot_enter!=penter) {
claraluques 12:64ed645e79ad 220 if (linha==2){
claraluques 12:64ed645e79ad 221 func = 12;
claraluques 12:64ed645e79ad 222 }
claraluques 12:64ed645e79ad 223 else if (linha==3){
claraluques 12:64ed645e79ad 224 func = 1;
claraluques 12:64ed645e79ad 225 }
claraluques 12:64ed645e79ad 226 }
claraluques 12:64ed645e79ad 227 }
claraluques 9:86b5a317fcd4 228
claraluques 9:86b5a317fcd4 229 //func 4
claraluques 13:1670c34440a5 230 void config() {
claraluques 13:1670c34440a5 231 lcd.cls();
claraluques 13:1670c34440a5 232 bot_enter = 0;
claraluques 13:1670c34440a5 233 lcd.locate(1,0);
claraluques 13:1670c34440a5 234 lcd.printf("Definir velocidade");
claraluques 13:1670c34440a5 235 lcd.locate(1,1);
claraluques 13:1670c34440a5 236 lcd.printf("Limpar seringa cola");
claraluques 13:1670c34440a5 237 lcd.locate(1,2);
claraluques 13:1670c34440a5 238 lcd.printf("Desligar a maquina");
claraluques 13:1670c34440a5 239 lcd.locate(1,3);
claraluques 13:1670c34440a5 240 lcd.printf("Voltar");
claraluques 13:1670c34440a5 241 movercursor(0,3,0);
claraluques 13:1670c34440a5 242 if (bot_enter!=penter){
claraluques 13:1670c34440a5 243 if (linha==0) {
claraluques 13:1670c34440a5 244 func = 13;
claraluques 13:1670c34440a5 245 }
claraluques 13:1670c34440a5 246 else if (linha==1) {
claraluques 13:1670c34440a5 247 func = 14;
claraluques 13:1670c34440a5 248 }
claraluques 13:1670c34440a5 249 else if (linha==2) {
claraluques 13:1670c34440a5 250 func = 15;
claraluques 13:1670c34440a5 251 }
claraluques 13:1670c34440a5 252 else if (linha==3) {
claraluques 13:1670c34440a5 253 func = 1;
claraluques 13:1670c34440a5 254 }
claraluques 13:1670c34440a5 255 }
claraluques 13:1670c34440a5 256 }
claraluques 9:86b5a317fcd4 257
claraluques 8:b80f50544ddd 258 //func 5
claraluques 9:86b5a317fcd4 259 void telasalvamento(){ //função para quando salvar um ponto
claraluques 8:b80f50544ddd 260 lcd.cls();
claraluques 8:b80f50544ddd 261 lcd.locate(0,0);
claraluques 13:1670c34440a5 262 lcd.printf("Voce salvou");
claraluques 13:1670c34440a5 263 lcd.locate(1,1);
claraluques 13:1670c34440a5 264 lcd.printf("X:%.3f", cx_salva);
claraluques 13:1670c34440a5 265 lcd.locate(1,2);
claraluques 13:1670c34440a5 266 lcd.printf("Y:%.3f", cy_salva);
claraluques 13:1670c34440a5 267 lcd.locate(1,3);
claraluques 13:1670c34440a5 268 lcd.printf("Z:%.3f", cz_salva);
claraluques 13:1670c34440a5 269 lcd.locate(13,1);
claraluques 13:1670c34440a5 270 lcd.printf("Pontos");
claraluques 13:1670c34440a5 271 lcd.locate(13,2);
claraluques 13:1670c34440a5 272 lcd.printf("livres");
claraluques 13:1670c34440a5 273 lcd.locate(16,3);
claraluques 13:1670c34440a5 274 lcd.printf("%d", pontos);
claraluques 9:86b5a317fcd4 275 wait(1);
claraluques 13:1670c34440a5 276 if (pontos>0){
claraluques 13:1670c34440a5 277 func = 6;
claraluques 13:1670c34440a5 278 }
claraluques 13:1670c34440a5 279 else if (pontos==0){
claraluques 13:1670c34440a5 280 func = 2;
claraluques 13:1670c34440a5 281 }
claraluques 8:b80f50544ddd 282 }
claraluques 8:b80f50544ddd 283
claraluques 9:86b5a317fcd4 284 //func 6
claraluques 9:86b5a317fcd4 285 void telacola(){ //tela para escolher o tipo de sequencia da cola
claraluques 9:86b5a317fcd4 286 lcd.cls();
claraluques 9:86b5a317fcd4 287 bot_enter = 0;
claraluques 9:86b5a317fcd4 288 lcd.printf("P/ o proximo ponto:");
claraluques 9:86b5a317fcd4 289 lcd.locate(3,1);
claraluques 9:86b5a317fcd4 290 lcd.printf("Sem cola");
claraluques 9:86b5a317fcd4 291 lcd.locate(3,2);
claraluques 9:86b5a317fcd4 292 lcd.printf("Cola no ponto");
claraluques 9:86b5a317fcd4 293 lcd.locate(3,3);
claraluques 9:86b5a317fcd4 294 lcd.printf("Cola continua");
claraluques 9:86b5a317fcd4 295 movercursor(1,3,2);
claraluques 9:86b5a317fcd4 296 if (bot_enter!=penter){
claraluques 9:86b5a317fcd4 297 if (linha==1){
claraluques 9:86b5a317fcd4 298 cola = 0;
claraluques 9:86b5a317fcd4 299 func = 2;
claraluques 9:86b5a317fcd4 300 }
claraluques 9:86b5a317fcd4 301 else if (linha==2) {
claraluques 9:86b5a317fcd4 302 cola = 1;
claraluques 9:86b5a317fcd4 303 func = 2;
claraluques 9:86b5a317fcd4 304 }
claraluques 9:86b5a317fcd4 305 else if (linha==3) {
claraluques 9:86b5a317fcd4 306 cola = 2;
claraluques 9:86b5a317fcd4 307 func = 2;
claraluques 9:86b5a317fcd4 308 }
claraluques 9:86b5a317fcd4 309 }
claraluques 9:86b5a317fcd4 310 }
claraluques 9:86b5a317fcd4 311
claraluques 9:86b5a317fcd4 312 //func 7
claraluques 9:86b5a317fcd4 313 void executarprograma() { //tela para selecionar se deseja executar o programa
claraluques 9:86b5a317fcd4 314 lcd.cls();
claraluques 9:86b5a317fcd4 315 bot_enter = 0;
claraluques 9:86b5a317fcd4 316 lcd.locate(2,0);
claraluques 9:86b5a317fcd4 317 lcd.printf("VOCE CONCLUIU SEU");
claraluques 9:86b5a317fcd4 318 lcd.locate(5,1);
claraluques 9:86b5a317fcd4 319 lcd.printf("PROGRAMA.");
claraluques 9:86b5a317fcd4 320 lcd.locate(0,2);
claraluques 9:86b5a317fcd4 321 lcd.printf("Deseja");
claraluques 9:86b5a317fcd4 322 lcd.locate(0,3);
claraluques 9:86b5a317fcd4 323 lcd.printf("executa-lo?");
claraluques 9:86b5a317fcd4 324 lcd.locate(14,2);
claraluques 9:86b5a317fcd4 325 lcd.printf("Sim");
claraluques 9:86b5a317fcd4 326 lcd.locate(14,3);
claraluques 9:86b5a317fcd4 327 lcd.printf("Voltar");
claraluques 9:86b5a317fcd4 328 movercursor(2,3,13);
claraluques 9:86b5a317fcd4 329 if (bot_enter!=penter) {
claraluques 9:86b5a317fcd4 330 if (linha==2){
claraluques 9:86b5a317fcd4 331 exec = 1;
claraluques 9:86b5a317fcd4 332 func = 9;
claraluques 9:86b5a317fcd4 333 }
claraluques 9:86b5a317fcd4 334 else if (linha==3){
claraluques 9:86b5a317fcd4 335 exec = 0;
claraluques 9:86b5a317fcd4 336 func = 2;
claraluques 9:86b5a317fcd4 337 }
claraluques 9:86b5a317fcd4 338 }
claraluques 9:86b5a317fcd4 339 }
claraluques 9:86b5a317fcd4 340
claraluques 9:86b5a317fcd4 341 //func 8
claraluques 9:86b5a317fcd4 342 void telazerar(){ //tela para zerar a máquina
claraluques 9:86b5a317fcd4 343 lcd.cls();
claraluques 9:86b5a317fcd4 344 bot_enter = 0;
claraluques 9:86b5a317fcd4 345 lcd.locate(2,0);
claraluques 9:86b5a317fcd4 346 lcd.printf("Pressione OK para zerar as coordenadas");
claraluques 9:86b5a317fcd4 347 lcd.locate(7,2);
claraluques 9:86b5a317fcd4 348 lcd.printf("OK");
claraluques 9:86b5a317fcd4 349 lcd.locate(7,3);
claraluques 9:86b5a317fcd4 350 lcd.printf("Voltar");
claraluques 9:86b5a317fcd4 351 movercursor(2,3,6);
claraluques 9:86b5a317fcd4 352 if (bot_enter!=penter) {
claraluques 9:86b5a317fcd4 353 if (linha==2){
claraluques 9:86b5a317fcd4 354 cx = 0;
claraluques 9:86b5a317fcd4 355 cy = 0;
claraluques 9:86b5a317fcd4 356 cz = 0;
claraluques 9:86b5a317fcd4 357 func = 10;
claraluques 9:86b5a317fcd4 358 }
claraluques 9:86b5a317fcd4 359 else if (linha==3){
claraluques 9:86b5a317fcd4 360 func = 1;
claraluques 9:86b5a317fcd4 361 }
claraluques 9:86b5a317fcd4 362 }
claraluques 9:86b5a317fcd4 363 }
claraluques 9:86b5a317fcd4 364
claraluques 9:86b5a317fcd4 365 //func 9
claraluques 9:86b5a317fcd4 366 void executando(){ //tela de executando
claraluques 9:86b5a317fcd4 367 lcd.cls();
claraluques 9:86b5a317fcd4 368 lcd.locate(4,1);
claraluques 9:86b5a317fcd4 369 lcd.printf("Executando");
claraluques 9:86b5a317fcd4 370 int contador = 0;
claraluques 9:86b5a317fcd4 371 while (exec==1){
claraluques 9:86b5a317fcd4 372 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 373 lcd.printf(". ");
claraluques 9:86b5a317fcd4 374 wait(0.5);
claraluques 9:86b5a317fcd4 375 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 376 lcd.printf(".. ");
claraluques 9:86b5a317fcd4 377 wait(0.5);
claraluques 9:86b5a317fcd4 378 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 379 lcd.printf("...");
claraluques 9:86b5a317fcd4 380 wait(0.5);
claraluques 9:86b5a317fcd4 381 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 382 lcd.printf(" ");
claraluques 9:86b5a317fcd4 383 wait(0.5);
claraluques 9:86b5a317fcd4 384 contador++;
claraluques 9:86b5a317fcd4 385 if (contador>=2){
claraluques 9:86b5a317fcd4 386 exec = 0;
claraluques 9:86b5a317fcd4 387 func = 11;
claraluques 9:86b5a317fcd4 388 }
claraluques 9:86b5a317fcd4 389 }
claraluques 9:86b5a317fcd4 390 }
claraluques 9:86b5a317fcd4 391
claraluques 9:86b5a317fcd4 392 //func 10
claraluques 9:86b5a317fcd4 393 void zerado() { //tela avisando que a máquina foi zerada
claraluques 9:86b5a317fcd4 394 lcd.cls();
claraluques 9:86b5a317fcd4 395 lcd.locate(5,1);
claraluques 9:86b5a317fcd4 396 lcd.printf("Voce zerou");
claraluques 9:86b5a317fcd4 397 lcd.locate(5,2);
claraluques 9:86b5a317fcd4 398 lcd.printf("a maquina!");
claraluques 9:86b5a317fcd4 399 wait(1);
claraluques 9:86b5a317fcd4 400 func = 8;
claraluques 9:86b5a317fcd4 401 }
claraluques 9:86b5a317fcd4 402
claraluques 9:86b5a317fcd4 403 //func 11
claraluques 14:ec8d10a34a2c 404 void finalizado() { //tela aviso programa finalizado
claraluques 9:86b5a317fcd4 405 lcd.cls();
claraluques 9:86b5a317fcd4 406 lcd.locate(6,1);
claraluques 9:86b5a317fcd4 407 lcd.printf("PROGRAMA");
claraluques 9:86b5a317fcd4 408 lcd.locate(5,2);
claraluques 9:86b5a317fcd4 409 lcd.printf("FINALIZADO");
claraluques 9:86b5a317fcd4 410 wait(1);
claraluques 9:86b5a317fcd4 411 func = 1;
claraluques 13:1670c34440a5 412 }
claraluques 13:1670c34440a5 413
claraluques 13:1670c34440a5 414 //func 12
claraluques 13:1670c34440a5 415
claraluques 13:1670c34440a5 416 //func 13
claraluques 13:1670c34440a5 417
claraluques 13:1670c34440a5 418 //func 14
claraluques 13:1670c34440a5 419
claraluques 13:1670c34440a5 420 //func 15
claraluques 13:1670c34440a5 421
claraluques 13:1670c34440a5 422 //func 16
claraluques 14:ec8d10a34a2c 423 void limitepontos(){ //tela para quando acabam os pontos
claraluques 13:1670c34440a5 424 lcd.cls();
claraluques 13:1670c34440a5 425 lcd.printf(" Voce atingiu o n%c maximo de pontos.", 0xDF);
claraluques 13:1670c34440a5 426 lcd.locate(0,3);
claraluques 13:1670c34440a5 427 lcd.printf("Conclua seu programa");
claraluques 13:1670c34440a5 428 wait(1);
claraluques 13:1670c34440a5 429 func = 2;
claraluques 13:1670c34440a5 430 }
claraluques 9:86b5a317fcd4 431
claraluques 9:86b5a317fcd4 432 Menu(); //não apagar
claraluques 19:2c890ae2d187 433 };*/
wim 1:ef419b21167d 434
claraluques 9:86b5a317fcd4 435 Menu::Menu(){ //não apagar
claraluques 12:64ed645e79ad 436 func = 0;
claraluques 9:86b5a317fcd4 437 }
wim 3:f238b4f7874f 438
claraluques 19:2c890ae2d187 439 Machine machine;
claraluques 5:30f5ffe0ea0b 440 Menu menu;
claraluques 19:2c890ae2d187 441
wim 3:f238b4f7874f 442
claraluques 5:30f5ffe0ea0b 443 int main () {
claraluques 5:30f5ffe0ea0b 444 lcd.setBacklight(TextLCD::LightOn); //liga backlight
claraluques 9:86b5a317fcd4 445 lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor
claraluques 5:30f5ffe0ea0b 446
claraluques 9:86b5a317fcd4 447 botao_enter.rise(&botenter_press); //chama função botao enter
claraluques 9:86b5a317fcd4 448 botao_cima.rise(&botcima_press); //chama função botao para cima
claraluques 9:86b5a317fcd4 449 botao_baixo.rise(&botbaixo_press); //chama função bota para baixo
claraluques 6:24cbbdf2dac2 450
claraluques 5:30f5ffe0ea0b 451 while(1){
claraluques 9:86b5a317fcd4 452 switch(menu.func){ //faz com que as telas sejam iniciadas
claraluques 5:30f5ffe0ea0b 453 case 0: menu.inicializar(); break;
claraluques 5:30f5ffe0ea0b 454 case 1: menu.menuprincipal(); break;
claraluques 6:24cbbdf2dac2 455 case 2: menu.jog(); break;
claraluques 12:64ed645e79ad 456 case 3: menu.automatico(); break;
claraluques 13:1670c34440a5 457 case 4: menu.config(); break;
claraluques 9:86b5a317fcd4 458 case 5: menu.telasalvamento(); break;
claraluques 9:86b5a317fcd4 459 case 6: menu.telacola(); break;
claraluques 9:86b5a317fcd4 460 case 7: menu.executarprograma(); break;
claraluques 9:86b5a317fcd4 461 case 8: menu.telazerar(); break;
claraluques 9:86b5a317fcd4 462 case 9: menu.executando(); break;
claraluques 9:86b5a317fcd4 463 case 10: menu.zerado(); break;
claraluques 9:86b5a317fcd4 464 case 11: menu.finalizado(); break;
claraluques 13:1670c34440a5 465 case 16: menu.limitepontos(); break;
claraluques 5:30f5ffe0ea0b 466 }
claraluques 5:30f5ffe0ea0b 467 }
claraluques 11:6b7accf18fe2 468 }
claraluques 5:30f5ffe0ea0b 469
claraluques 11:6b7accf18fe2 470 //função interrupt botão enter
claraluques 11:6b7accf18fe2 471 void botenter_press(void){
claraluques 11:6b7accf18fe2 472 penter = bot_enter;
claraluques 11:6b7accf18fe2 473 bot_enter = !bot_enter;
claraluques 11:6b7accf18fe2 474 printf("enter high");
claraluques 11:6b7accf18fe2 475 }
claraluques 9:86b5a317fcd4 476
claraluques 11:6b7accf18fe2 477 //função interrupt botão cima
claraluques 11:6b7accf18fe2 478 void botcima_press(void){
claraluques 11:6b7accf18fe2 479 pcima = bot_cima;
claraluques 11:6b7accf18fe2 480 bot_cima = !bot_cima;
claraluques 11:6b7accf18fe2 481 printf("cima high");
claraluques 11:6b7accf18fe2 482 }
wim 0:a75049de1a82 483
claraluques 5:30f5ffe0ea0b 484 //função interrupt botão baixo
claraluques 11:6b7accf18fe2 485 void botbaixo_press(void){
claraluques 11:6b7accf18fe2 486 pbaixo = bot_baixo;
claraluques 11:6b7accf18fe2 487 bot_baixo = !bot_baixo;
claraluques 11:6b7accf18fe2 488 printf("baixo high");
claraluques 19:2c890ae2d187 489 }
claraluques 18:5338b83b4de9 490