Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Committer:
claraluques
Date:
Mon May 14 17:33:12 2018 +0000
Revision:
16:6912d19a0016
Parent:
15:043bb371a50b
Child:
18:5338b83b4de9
coordenadas no while para mudarem constantemente;

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