Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Committer:
claraluques
Date:
Fri May 11 18:13:38 2018 +0000
Revision:
13:1670c34440a5
Parent:
12:64ed645e79ad
Child:
14:ec8d10a34a2c
limite de pontos e mais algumas telas

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 13:1670c34440a5 30 int pontos = 1;
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 6:24cbbdf2dac2 175 }
claraluques 6:24cbbdf2dac2 176 }
claraluques 6:24cbbdf2dac2 177 }
claraluques 6:24cbbdf2dac2 178
claraluques 9:86b5a317fcd4 179 //func 3
claraluques 12:64ed645e79ad 180 void automatico(){ //tela modo automatico
claraluques 12:64ed645e79ad 181 lcd.cls();
claraluques 12:64ed645e79ad 182 bot_enter = 0;
claraluques 12:64ed645e79ad 183 lcd.printf("Modo automatico");
claraluques 12:64ed645e79ad 184 lcd.locate(7,2);
claraluques 12:64ed645e79ad 185 lcd.printf("OK");
claraluques 12:64ed645e79ad 186 lcd.locate(7,3);
claraluques 12:64ed645e79ad 187 lcd.printf("Voltar");
claraluques 12:64ed645e79ad 188 movercursor(2,3,6);
claraluques 12:64ed645e79ad 189 if (bot_enter!=penter) {
claraluques 12:64ed645e79ad 190 if (linha==2){
claraluques 12:64ed645e79ad 191 func = 12;
claraluques 12:64ed645e79ad 192 }
claraluques 12:64ed645e79ad 193 else if (linha==3){
claraluques 12:64ed645e79ad 194 func = 1;
claraluques 12:64ed645e79ad 195 }
claraluques 12:64ed645e79ad 196 }
claraluques 12:64ed645e79ad 197 }
claraluques 9:86b5a317fcd4 198
claraluques 9:86b5a317fcd4 199 //func 4
claraluques 13:1670c34440a5 200 void config() {
claraluques 13:1670c34440a5 201 lcd.cls();
claraluques 13:1670c34440a5 202 bot_enter = 0;
claraluques 13:1670c34440a5 203 lcd.locate(1,0);
claraluques 13:1670c34440a5 204 lcd.printf("Definir velocidade");
claraluques 13:1670c34440a5 205 lcd.locate(1,1);
claraluques 13:1670c34440a5 206 lcd.printf("Limpar seringa cola");
claraluques 13:1670c34440a5 207 lcd.locate(1,2);
claraluques 13:1670c34440a5 208 lcd.printf("Desligar a maquina");
claraluques 13:1670c34440a5 209 lcd.locate(1,3);
claraluques 13:1670c34440a5 210 lcd.printf("Voltar");
claraluques 13:1670c34440a5 211 movercursor(0,3,0);
claraluques 13:1670c34440a5 212 if (bot_enter!=penter){
claraluques 13:1670c34440a5 213 if (linha==0) {
claraluques 13:1670c34440a5 214 func = 13;
claraluques 13:1670c34440a5 215 }
claraluques 13:1670c34440a5 216 else if (linha==1) {
claraluques 13:1670c34440a5 217 func = 14;
claraluques 13:1670c34440a5 218 }
claraluques 13:1670c34440a5 219 else if (linha==2) {
claraluques 13:1670c34440a5 220 func = 15;
claraluques 13:1670c34440a5 221 }
claraluques 13:1670c34440a5 222 else if (linha==3) {
claraluques 13:1670c34440a5 223 func = 1;
claraluques 13:1670c34440a5 224 }
claraluques 13:1670c34440a5 225 }
claraluques 13:1670c34440a5 226 }
claraluques 9:86b5a317fcd4 227
claraluques 8:b80f50544ddd 228 //func 5
claraluques 9:86b5a317fcd4 229 void telasalvamento(){ //função para quando salvar um ponto
claraluques 8:b80f50544ddd 230 lcd.cls();
claraluques 8:b80f50544ddd 231 lcd.locate(0,0);
claraluques 13:1670c34440a5 232 lcd.printf("Voce salvou");
claraluques 13:1670c34440a5 233 lcd.locate(1,1);
claraluques 13:1670c34440a5 234 lcd.printf("X:%.3f", cx_salva);
claraluques 13:1670c34440a5 235 lcd.locate(1,2);
claraluques 13:1670c34440a5 236 lcd.printf("Y:%.3f", cy_salva);
claraluques 13:1670c34440a5 237 lcd.locate(1,3);
claraluques 13:1670c34440a5 238 lcd.printf("Z:%.3f", cz_salva);
claraluques 13:1670c34440a5 239 lcd.locate(13,1);
claraluques 13:1670c34440a5 240 lcd.printf("Pontos");
claraluques 13:1670c34440a5 241 lcd.locate(13,2);
claraluques 13:1670c34440a5 242 lcd.printf("livres");
claraluques 13:1670c34440a5 243 lcd.locate(16,3);
claraluques 13:1670c34440a5 244 lcd.printf("%d", pontos);
claraluques 9:86b5a317fcd4 245 wait(1);
claraluques 13:1670c34440a5 246 if (pontos>0){
claraluques 13:1670c34440a5 247 func = 6;
claraluques 13:1670c34440a5 248 }
claraluques 13:1670c34440a5 249 else if (pontos==0){
claraluques 13:1670c34440a5 250 func = 2;
claraluques 13:1670c34440a5 251 }
claraluques 8:b80f50544ddd 252 }
claraluques 8:b80f50544ddd 253
claraluques 9:86b5a317fcd4 254 //func 6
claraluques 9:86b5a317fcd4 255 void telacola(){ //tela para escolher o tipo de sequencia da cola
claraluques 9:86b5a317fcd4 256 lcd.cls();
claraluques 9:86b5a317fcd4 257 bot_enter = 0;
claraluques 9:86b5a317fcd4 258 lcd.printf("P/ o proximo ponto:");
claraluques 9:86b5a317fcd4 259 lcd.locate(3,1);
claraluques 9:86b5a317fcd4 260 lcd.printf("Sem cola");
claraluques 9:86b5a317fcd4 261 lcd.locate(3,2);
claraluques 9:86b5a317fcd4 262 lcd.printf("Cola no ponto");
claraluques 9:86b5a317fcd4 263 lcd.locate(3,3);
claraluques 9:86b5a317fcd4 264 lcd.printf("Cola continua");
claraluques 9:86b5a317fcd4 265 movercursor(1,3,2);
claraluques 9:86b5a317fcd4 266 if (bot_enter!=penter){
claraluques 9:86b5a317fcd4 267 if (linha==1){
claraluques 9:86b5a317fcd4 268 cola = 0;
claraluques 9:86b5a317fcd4 269 func = 2;
claraluques 9:86b5a317fcd4 270 }
claraluques 9:86b5a317fcd4 271 else if (linha==2) {
claraluques 9:86b5a317fcd4 272 cola = 1;
claraluques 9:86b5a317fcd4 273 func = 2;
claraluques 9:86b5a317fcd4 274 }
claraluques 9:86b5a317fcd4 275 else if (linha==3) {
claraluques 9:86b5a317fcd4 276 cola = 2;
claraluques 9:86b5a317fcd4 277 func = 2;
claraluques 9:86b5a317fcd4 278 }
claraluques 9:86b5a317fcd4 279 }
claraluques 9:86b5a317fcd4 280 }
claraluques 9:86b5a317fcd4 281
claraluques 9:86b5a317fcd4 282 //func 7
claraluques 9:86b5a317fcd4 283 void executarprograma() { //tela para selecionar se deseja executar o programa
claraluques 9:86b5a317fcd4 284 lcd.cls();
claraluques 9:86b5a317fcd4 285 bot_enter = 0;
claraluques 9:86b5a317fcd4 286 lcd.locate(2,0);
claraluques 9:86b5a317fcd4 287 lcd.printf("VOCE CONCLUIU SEU");
claraluques 9:86b5a317fcd4 288 lcd.locate(5,1);
claraluques 9:86b5a317fcd4 289 lcd.printf("PROGRAMA.");
claraluques 9:86b5a317fcd4 290 lcd.locate(0,2);
claraluques 9:86b5a317fcd4 291 lcd.printf("Deseja");
claraluques 9:86b5a317fcd4 292 lcd.locate(0,3);
claraluques 9:86b5a317fcd4 293 lcd.printf("executa-lo?");
claraluques 9:86b5a317fcd4 294 lcd.locate(14,2);
claraluques 9:86b5a317fcd4 295 lcd.printf("Sim");
claraluques 9:86b5a317fcd4 296 lcd.locate(14,3);
claraluques 9:86b5a317fcd4 297 lcd.printf("Voltar");
claraluques 9:86b5a317fcd4 298 movercursor(2,3,13);
claraluques 9:86b5a317fcd4 299 if (bot_enter!=penter) {
claraluques 9:86b5a317fcd4 300 if (linha==2){
claraluques 9:86b5a317fcd4 301 exec = 1;
claraluques 9:86b5a317fcd4 302 func = 9;
claraluques 9:86b5a317fcd4 303 }
claraluques 9:86b5a317fcd4 304 else if (linha==3){
claraluques 9:86b5a317fcd4 305 exec = 0;
claraluques 9:86b5a317fcd4 306 func = 2;
claraluques 9:86b5a317fcd4 307 }
claraluques 9:86b5a317fcd4 308 }
claraluques 9:86b5a317fcd4 309 }
claraluques 9:86b5a317fcd4 310
claraluques 9:86b5a317fcd4 311 //func 8
claraluques 9:86b5a317fcd4 312 void telazerar(){ //tela para zerar a máquina
claraluques 9:86b5a317fcd4 313 lcd.cls();
claraluques 9:86b5a317fcd4 314 bot_enter = 0;
claraluques 9:86b5a317fcd4 315 lcd.locate(2,0);
claraluques 9:86b5a317fcd4 316 lcd.printf("Pressione OK para zerar as coordenadas");
claraluques 9:86b5a317fcd4 317 lcd.locate(7,2);
claraluques 9:86b5a317fcd4 318 lcd.printf("OK");
claraluques 9:86b5a317fcd4 319 lcd.locate(7,3);
claraluques 9:86b5a317fcd4 320 lcd.printf("Voltar");
claraluques 9:86b5a317fcd4 321 movercursor(2,3,6);
claraluques 9:86b5a317fcd4 322 if (bot_enter!=penter) {
claraluques 9:86b5a317fcd4 323 if (linha==2){
claraluques 9:86b5a317fcd4 324 cx = 0;
claraluques 9:86b5a317fcd4 325 cy = 0;
claraluques 9:86b5a317fcd4 326 cz = 0;
claraluques 9:86b5a317fcd4 327 func = 10;
claraluques 9:86b5a317fcd4 328 }
claraluques 9:86b5a317fcd4 329 else if (linha==3){
claraluques 9:86b5a317fcd4 330 func = 1;
claraluques 9:86b5a317fcd4 331 }
claraluques 9:86b5a317fcd4 332 }
claraluques 9:86b5a317fcd4 333 }
claraluques 9:86b5a317fcd4 334
claraluques 9:86b5a317fcd4 335 //func 9
claraluques 9:86b5a317fcd4 336 void executando(){ //tela de executando
claraluques 9:86b5a317fcd4 337 lcd.cls();
claraluques 9:86b5a317fcd4 338 lcd.locate(4,1);
claraluques 9:86b5a317fcd4 339 lcd.printf("Executando");
claraluques 9:86b5a317fcd4 340 int contador = 0;
claraluques 9:86b5a317fcd4 341 while (exec==1){
claraluques 9:86b5a317fcd4 342 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 343 lcd.printf(". ");
claraluques 9:86b5a317fcd4 344 wait(0.5);
claraluques 9:86b5a317fcd4 345 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 346 lcd.printf(".. ");
claraluques 9:86b5a317fcd4 347 wait(0.5);
claraluques 9:86b5a317fcd4 348 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 349 lcd.printf("...");
claraluques 9:86b5a317fcd4 350 wait(0.5);
claraluques 9:86b5a317fcd4 351 lcd.locate(14,1);
claraluques 9:86b5a317fcd4 352 lcd.printf(" ");
claraluques 9:86b5a317fcd4 353 wait(0.5);
claraluques 9:86b5a317fcd4 354 contador++;
claraluques 9:86b5a317fcd4 355 if (contador>=2){
claraluques 9:86b5a317fcd4 356 exec = 0;
claraluques 9:86b5a317fcd4 357 func = 11;
claraluques 9:86b5a317fcd4 358 }
claraluques 9:86b5a317fcd4 359 }
claraluques 9:86b5a317fcd4 360 }
claraluques 9:86b5a317fcd4 361
claraluques 9:86b5a317fcd4 362 //func 10
claraluques 9:86b5a317fcd4 363 void zerado() { //tela avisando que a máquina foi zerada
claraluques 9:86b5a317fcd4 364 lcd.cls();
claraluques 9:86b5a317fcd4 365 lcd.locate(5,1);
claraluques 9:86b5a317fcd4 366 lcd.printf("Voce zerou");
claraluques 9:86b5a317fcd4 367 lcd.locate(5,2);
claraluques 9:86b5a317fcd4 368 lcd.printf("a maquina!");
claraluques 9:86b5a317fcd4 369 wait(1);
claraluques 9:86b5a317fcd4 370 func = 8;
claraluques 9:86b5a317fcd4 371 }
claraluques 9:86b5a317fcd4 372
claraluques 9:86b5a317fcd4 373 //func 11
claraluques 9:86b5a317fcd4 374 void finalizado() {
claraluques 9:86b5a317fcd4 375 lcd.cls();
claraluques 9:86b5a317fcd4 376 lcd.locate(6,1);
claraluques 9:86b5a317fcd4 377 lcd.printf("PROGRAMA");
claraluques 9:86b5a317fcd4 378 lcd.locate(5,2);
claraluques 9:86b5a317fcd4 379 lcd.printf("FINALIZADO");
claraluques 9:86b5a317fcd4 380 wait(1);
claraluques 9:86b5a317fcd4 381 func = 1;
claraluques 13:1670c34440a5 382 }
claraluques 13:1670c34440a5 383
claraluques 13:1670c34440a5 384 //func 12
claraluques 13:1670c34440a5 385
claraluques 13:1670c34440a5 386 //func 13
claraluques 13:1670c34440a5 387
claraluques 13:1670c34440a5 388 //func 14
claraluques 13:1670c34440a5 389
claraluques 13:1670c34440a5 390 //func 15
claraluques 13:1670c34440a5 391
claraluques 13:1670c34440a5 392 //func 16
claraluques 13:1670c34440a5 393 void limitepontos(){
claraluques 13:1670c34440a5 394 lcd.cls();
claraluques 13:1670c34440a5 395 lcd.printf(" Voce atingiu o n%c maximo de pontos.", 0xDF);
claraluques 13:1670c34440a5 396 lcd.locate(0,3);
claraluques 13:1670c34440a5 397 lcd.printf("Conclua seu programa");
claraluques 13:1670c34440a5 398 wait(1);
claraluques 13:1670c34440a5 399 func = 2;
claraluques 13:1670c34440a5 400 }
claraluques 9:86b5a317fcd4 401
claraluques 9:86b5a317fcd4 402 Menu(); //não apagar
claraluques 5:30f5ffe0ea0b 403 };
wim 1:ef419b21167d 404
claraluques 9:86b5a317fcd4 405 Menu::Menu(){ //não apagar
claraluques 12:64ed645e79ad 406 func = 0;
claraluques 9:86b5a317fcd4 407 }
wim 3:f238b4f7874f 408
claraluques 5:30f5ffe0ea0b 409 Menu menu;
wim 3:f238b4f7874f 410
claraluques 5:30f5ffe0ea0b 411 int main () {
claraluques 5:30f5ffe0ea0b 412 lcd.setBacklight(TextLCD::LightOn); //liga backlight
claraluques 9:86b5a317fcd4 413 lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor
claraluques 5:30f5ffe0ea0b 414
claraluques 9:86b5a317fcd4 415 botao_enter.rise(&botenter_press); //chama função botao enter
claraluques 9:86b5a317fcd4 416 botao_cima.rise(&botcima_press); //chama função botao para cima
claraluques 9:86b5a317fcd4 417 botao_baixo.rise(&botbaixo_press); //chama função bota para baixo
claraluques 6:24cbbdf2dac2 418
claraluques 5:30f5ffe0ea0b 419 while(1){
claraluques 9:86b5a317fcd4 420 switch(menu.func){ //faz com que as telas sejam iniciadas
claraluques 5:30f5ffe0ea0b 421 case 0: menu.inicializar(); break;
claraluques 5:30f5ffe0ea0b 422 case 1: menu.menuprincipal(); break;
claraluques 6:24cbbdf2dac2 423 case 2: menu.jog(); break;
claraluques 12:64ed645e79ad 424 case 3: menu.automatico(); break;
claraluques 13:1670c34440a5 425 case 4: menu.config(); break;
claraluques 9:86b5a317fcd4 426 case 5: menu.telasalvamento(); break;
claraluques 9:86b5a317fcd4 427 case 6: menu.telacola(); break;
claraluques 9:86b5a317fcd4 428 case 7: menu.executarprograma(); break;
claraluques 9:86b5a317fcd4 429 case 8: menu.telazerar(); break;
claraluques 9:86b5a317fcd4 430 case 9: menu.executando(); break;
claraluques 9:86b5a317fcd4 431 case 10: menu.zerado(); break;
claraluques 9:86b5a317fcd4 432 case 11: menu.finalizado(); break;
claraluques 13:1670c34440a5 433 case 16: menu.limitepontos(); break;
claraluques 5:30f5ffe0ea0b 434 }
claraluques 5:30f5ffe0ea0b 435 }
claraluques 11:6b7accf18fe2 436 }
claraluques 5:30f5ffe0ea0b 437
claraluques 11:6b7accf18fe2 438 //função interrupt botão enter
claraluques 11:6b7accf18fe2 439 void botenter_press(void){
claraluques 11:6b7accf18fe2 440 penter = bot_enter;
claraluques 11:6b7accf18fe2 441 bot_enter = !bot_enter;
claraluques 11:6b7accf18fe2 442 printf("enter high");
claraluques 11:6b7accf18fe2 443 }
claraluques 9:86b5a317fcd4 444
claraluques 11:6b7accf18fe2 445 //função interrupt botão cima
claraluques 11:6b7accf18fe2 446 void botcima_press(void){
claraluques 11:6b7accf18fe2 447 pcima = bot_cima;
claraluques 11:6b7accf18fe2 448 bot_cima = !bot_cima;
claraluques 11:6b7accf18fe2 449 printf("cima high");
claraluques 11:6b7accf18fe2 450 }
wim 0:a75049de1a82 451
claraluques 5:30f5ffe0ea0b 452 //função interrupt botão baixo
claraluques 11:6b7accf18fe2 453 void botbaixo_press(void){
claraluques 11:6b7accf18fe2 454 pbaixo = bot_baixo;
claraluques 11:6b7accf18fe2 455 bot_baixo = !bot_baixo;
claraluques 11:6b7accf18fe2 456 printf("baixo high");
claraluques 11:6b7accf18fe2 457 }