![](/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:
- 45:6701e27510f9
- Parent:
- 33:0149960e95c1
- Child:
- 46:31297622c5d1
--- a/classes.h Wed May 23 22:47:31 2018 +0000 +++ b/classes.h Fri May 25 15:11:08 2018 +0000 @@ -132,6 +132,9 @@ class SDCard{ public: int save_GCODE(string name, string gcode){ + printf("Saving: %s\n\r", name); + printf("Code: %s\n\r", gcode); + string file_path = "/sd/" + folderString + "/" + name; char * path = str_to_char(file_path); @@ -198,6 +201,7 @@ } int check_name_available(string name){ + printf("Checking name...\r\n"); string file_path = "/sd/" + folderString; char * dir = str_to_char(file_path); struct dirent *dirp; @@ -206,13 +210,15 @@ printf(dir); dp = opendir(dir); - + + t.reset(); t.start(); while((dirp = readdir(dp)) != NULL) { if(t.read() > 2.0){ t.stop(); closedir(dp); + printf("Timeout\r\n"); return 0; } filename = (dirp->d_name); @@ -550,7 +556,7 @@ cola = 2; func = 2; } - machine.save_point(cola,2); + machine.save_point(cola,1.0); } } @@ -774,19 +780,25 @@ //lcd.setCursor(TextLCD::CurOff_BlkOff); if (sair==1){ int len = nome.length(); - printf("%d\n\r", len); + //printf("%d\n\r", len); nome.erase(len - 1); nome.append(".txt"); - printf("%s\n\r", nome); + printf("Nome do programa: %s\n\r", nome); int verificar = sdcard.check_name_available(nome); - printf("%d", verificar); - if (verificar==1){ + printf("Status do nome: %d\n\r", verificar); + if (verificar){ file_name = nome; machine.get_saved_points(); + while(1){ + if(Mach.readable()){ + readSerial(); + break; + } + } printf("ok\n\r"); func = 7; } - else if (verificar==0){ + else if (!verificar){ func = 20; printf("nok\n\r"); } @@ -931,7 +943,7 @@ if (coluna<=18){ char carac = alfabeto[i]; nome.push_back(carac); - printf("%s\n\r", nome); + printf("Nome do programa (func - escrever): %s\n\r", nome); bot_enter = penter; if (coluna<18){ if (voltar==1){ @@ -977,24 +989,39 @@ string coordy = ""; string coordz = ""; string recv_buffer; + + int status; while(1){ recv = Mach.getc(); - printf("%c\n\r", recv); + if (recv == 'a'){ home = 0; exec = 0; printf("oi\n\r"); action = 1; - } + } + if (recv == 'p'){ points = 1; - } + } + if(recv == 'u'){ uploading_saved = 1; } - if (points){ + + if(uploading_saved){ + if(recv == 'x'){ + printf("OK\n\r"); + status = sdcard.save_GCODE(file_name, recv_buffer); + return; + } else if(recv != 'u'){ + recv_buffer.push_back(recv); + } + } + + if (points && !uploading_saved){ if (recv == 'X'){ pointx = 1; pointy = 0; @@ -1010,7 +1037,7 @@ pointx = 0; pointy = 0; } - else if (recv == 'x'){ + else if(recv == 'x'){ cx = atof(coordx.c_str()); cy = atof(coordy.c_str()); cz = atof(coordz.c_str()); @@ -1018,32 +1045,27 @@ break; } } - if (pointx){ + + if(pointx){ if (recv!='X'){ coordx.push_back(recv); } - } + } if (pointy){ if (recv!='Y'){ coordy.push_back(recv); } - } + } if (pointz){ if (recv!='Z'){ coordz.push_back(recv); } - } + } if (action){ if (recv=='x'){ break; } - } - if(recv == 'x' && uploading_saved){ - sdcard.save_GCODE(file_name, recv_buffer); - break; - } else if(uploading_saved && recv != 'u'){ - recv_buffer.push_back(recv); - } + } } }