Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Committer:
claraluques
Date:
Sat May 12 20:52:33 2018 +0000
Revision:
15:043bb371a50b
Parent:
14:ec8d10a34a2c
Child:
16:6912d19a0016
arrumei a variavel dos pontos apenas, para quando cancelar o jog eles voltem ao maximo

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