![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
Diff: classes.h
- Revision:
- 32:c293f89170b0
- Parent:
- 31:77eb51d4ee18
- Child:
- 33:0149960e95c1
--- a/classes.h Tue May 22 18:49:32 2018 +0000 +++ b/classes.h Wed May 23 14:54:13 2018 +0000 @@ -292,6 +292,7 @@ public: int linha; int func; + string nome; void movercursor(int min, int max, int col){ //função para mover cursor de seleção @@ -417,6 +418,13 @@ } } + + /*void inicializar(){ + while (1){ + printf("%d,%d\n\r", bot_enter, penter); + wait(0.5); + } + }*/ //func 0 void inicializar(){ //função tela incial de boas-vindas @@ -430,7 +438,6 @@ lcd.printf("Bem-vindo(a)"); lcd.locate(0,1); lcd.printf("Utilize seu EPI para operar a maquina."); - wait(1); /*status = sdcard.get_file_names(); @@ -440,8 +447,6 @@ printf("%s\n\r", filenames[i]); } }*/ - - wait(1); func = 1; } @@ -808,7 +813,7 @@ if (bot_enter!=penter){ if (linha==2){ salvar = 1; - printf("salvar\n\r"); + //printf("salvar\n\r"); func = 20; } if (linha==3){ @@ -848,48 +853,79 @@ //func 20 void nomeprog(){ - lcd.cls(); + nome = ""; + sair = 0; + lcd.cls(); bot_enter = penter; - lcd.printf("oieeee"); - printf("tela\n\r"); - escrever(3); - if (bot_enter!=penter){ - func = 1; + escrever(); + if (sair==1){ + printf("hey\n\r"); + nome.append(".txt"); + printf("%s\n\r", nome); + int verificar = sdcard.check_name_available(nome); + printf("%d", verificar); + if (verificar==1){ + file_name = nome; + machine.get_saved_points(); + printf("ok\n\r"); + func = 1; + } + else if (verificar==0){ + func = 21; + printf("nok\n\r"); + } } } + //func 21 + void mudar_nome(){ + lcd.cls(); + wait(1); + func = 20; + } + //função para escrever nome arquivo - void escrever(int coluna){ - char alfabeto[38] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', + void escrever(){ + char alfabeto[38] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', '0','1','2','3','4','5','6','7','8','9','-','_'}; - /*string alfabeto = "abcdefghijklmnopqrstuvwxyz0123456789-_";*/ int imax = 37; int imin = 0; - int i = 0; - printf("entrou\n\r"); - while (bot_enter==penter){ - if (bot_cima == 0){ - if (i==imin){ - i = imax; + lcd.locate(1,1); + while (sair==0){ + int i = 0; + lcd.locate(1,1); + lcd.printf("%s", nome); + while (bot_enter==penter){ + if (bot_cima == 0){ + if (i==imin){ + i = imax; + } + else if (i>imin && i<=imax){ + i--; + } + bot_cima = 1; } - else if (i>imin && i<=imax){ - i--; - } - bot_cima = 1; + else if (bot_baixo == 0){ + if (i==imax){ + i = imin; + } + else if (i<imax && i>=imin){ + i++; + } + bot_baixo = 1; + } + lcd.locate(coluna, 1); + lcd.printf("%c", alfabeto[i]); } - else if (bot_baixo == 0){ - if (i==imax){ - i = imin; - } - else if (i<imax && i>=imin){ - i++; + if (coluna<=18){ + if (coluna<18){ + coluna++; } - bot_baixo = 1; - } - - lcd.locate(coluna, 1); - lcd.printf("%c", alfabeto[i]); - //lcd.printf("oi"); + char carac = alfabeto[i]; + nome.push_back(carac); + printf("%s\n\r", nome); + bot_enter = penter; + } } } @@ -907,11 +943,11 @@ string coordz = ""; string recv_buffer; - + while(1){ recv = Mach.getc(); printf("%c\n\r", recv); - if (recv == 'a' /*&& points == 0*/){ + if (recv == 'a'){ home = 0; exec = 0; printf("oi\n\r");