Skip to content

Commit

Permalink
Merge pull request bigtreetech#50 from Msq001/master
Browse files Browse the repository at this point in the history
improve the compatibility of smoothieware print OnboardSD
  • Loading branch information
bigtreetech authored Sep 19, 2019
2 parents d0d4e5a + 2b59265 commit 5387467
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
Binary file not shown.
Binary file not shown.
10 changes: 3 additions & 7 deletions TFT/src/User/API/Gcode/gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void resetRequestCommandInfo(void)
bool request_M21(void)
{
strcpy(requestCommandInfo.command,"M21\n");
strcpy(requestCommandInfo.startMagic,echomagic);
strcpy(requestCommandInfo.startMagic,"SD card ok");
strcpy(requestCommandInfo.stopMagic,"\n");
strcpy(requestCommandInfo.errorMagic,"Error");

Expand All @@ -48,11 +48,7 @@ bool request_M21(void)
loopProcess();
}
// Check reponse
if(strstr(requestCommandInfo.cmd_rev_buf,echomagic) != NULL && strstr(requestCommandInfo.cmd_rev_buf,"SD card ok") != NULL){
return true;
} else {
return false;
}
return !requestHasTimeOut();
}

/*
Expand Down Expand Up @@ -99,7 +95,7 @@ char *request_M20(void)
long request_M23(char *filename)
{
sprintf(requestCommandInfo.command, "M23 %s\n",filename);
strcpy(requestCommandInfo.startMagic,echomagic);
strcpy(requestCommandInfo.startMagic, "File opened");
strcpy(requestCommandInfo.stopMagic,"File selected");
strcpy(requestCommandInfo.errorMagic,"open failed");
resetRequestCommandInfo();
Expand Down
17 changes: 11 additions & 6 deletions TFT/src/User/API/Gcode/mygcodefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ bool scanPrintFilesGcodeFs(void)
clearInfoFile();

char *data = request_M20();

const char s[2] = "\n";
char s[3];

if(strstr(data, "\r\n")) //for smoothieware
strcpy(s, "\r\n");
else //for Marlin
strcpy(s, "\n");

char *line = strtok(data, s);
for (;line != NULL;line = strtok(NULL, s))
{
if( strcmp(line,"Begin file list") == 0 || strcmp(line,"End file list") == 0 || strcmp(line,"ok") == 0)continue; // Start and Stop tag
if( strlen(line) < strlen(infoFile.title)-4) continue; // No path line exclude
if( strlen(infoFile.title) > 4 && strstr(line,infoFile.title+4) == NULL) continue; // No current directory
if ( strcmp(line,"Begin file list") == 0 || strcmp(line,"End file list") == 0 || strcmp(line,"ok") == 0) continue; // Start and Stop tag
if (strlen(line) < strlen(infoFile.title)-4) continue; // No path line exclude
if (strlen(infoFile.title) > 4 && strstr(line,infoFile.title+4) == NULL) continue; // No current directory

char *pline = line + strlen(infoFile.title) - 4;
if(strlen(infoFile.title) > 4)pline++;
if (strlen(infoFile.title) > 4)pline++;

if (strchr(pline, '/') == NULL)
{
Expand Down
7 changes: 6 additions & 1 deletion TFT/src/User/API/Language/Language.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ const char *const cz_pack[LABEL_NUM]={
CZ_FAN,
CZ_SETTINGS,
CZ_LEVELING,
CZ_POINT_1,
CZ_POINT_2,
CZ_POINT_3,
CZ_POINT_4,
CZ_ABL,
CZ_INC,
CZ_DEC,
CZ_NOZZLE,
Expand All @@ -605,7 +610,7 @@ const char *const cz_pack[LABEL_NUM]={
CZ_FAST_SPEED,
CZ_FAN_FULL_SPEED,
CZ_FAN_HALF_SPEED,
CZ_POWER_OFF,
CZ_ROTATE_UI,
CZ_TOUCHSCREEN_ADJUST,
CZ_SCREEN_INFO,
CZ_DISCONNECT,
Expand Down
13 changes: 9 additions & 4 deletions TFT/src/User/API/Language/language_cz.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#define CZ_FAN "Ofuk"
#define CZ_SETTINGS "Nastavení"
#define CZ_LEVELING "Leveling"
#define CZ_POINT_1 "Point 1"
#define CZ_POINT_2 "Point 2"
#define CZ_POINT_3 "Point 3"
#define CZ_POINT_4 "Point 4"
#define CZ_ABL "ABL"
#define CZ_INC "Přidat"
#define CZ_DEC "Ubrat"
#define CZ_NOZZLE "Tryska"
Expand All @@ -27,7 +32,7 @@
#define CZ_FAST_SPEED "Rychle"
#define CZ_FAN_FULL_SPEED "Plný"
#define CZ_FAN_HALF_SPEED "Poloviční"
#define CZ_POWER_OFF "Vypnout"
#define CZ_ROTATE_UI "Rotate UI"
#define CZ_TOUCHSCREEN_ADJUST "Kalibr.TFT"
#define CZ_SCREEN_INFO "Info"
#define CZ_DISCONNECT "Odpojit"
Expand All @@ -40,9 +45,9 @@
#define CZ_PERCENTAGE_SPEED "Rychlost"
#define CZ_PERCENTAGE_FLOW "Průtok"
#define CZ_VALUE_ZERO "Vypnout"
#define CZ_1_DEGREE "1��"
#define CZ_5_DEGREE "5��"
#define CZ_10_DEGREE "10��"
#define CZ_1_DEGREE "1C"
#define CZ_5_DEGREE "5C"
#define CZ_10_DEGREE "10C"
#define CZ_X_INC "X+"
#define CZ_Y_INC "Y+"
#define CZ_Z_INC "Z+"
Expand Down
9 changes: 6 additions & 3 deletions TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ void ackPopupInfo(const char *info)

void parseACK(void)
{
startParse:
if(infoHost.rx_ok[SERIAL_PORT] != true) return; //not get response data

infoHost.rx_ok[SERIAL_PORT] = false;
if(infoHost.connected == false) //not connected to Marlin
{
if((!ack_seen("T:") && !ack_seen("T0:")) || !ack_seen("ok")) goto parse_end; //the first response should be such as "T:25/50 ok\n"
Expand Down Expand Up @@ -100,7 +103,7 @@ void parseACK(void)
requestCommandInfo.inError = true;
gcodeProcessed = true;
}
if(requestCommandInfo.inResponse && ack_seen(requestCommandInfo.stopMagic ))
if(requestCommandInfo.inResponse && ack_seen(requestCommandInfo.stopMagic ))
{
requestCommandInfo.done = true;
requestCommandInfo.inResponse = false;
Expand Down Expand Up @@ -176,8 +179,8 @@ void parseACK(void)
}

parse_end:
infoHost.rx_ok[SERIAL_PORT] = false;

if(infoHost.rx_ok[SERIAL_PORT] == true) goto startParse; // receive new data in parseing, so need parse again
if(ack_cur_src != SERIAL_PORT)
{
Serial_Puts(ack_cur_src, ack_rev_buf);
Expand Down

0 comments on commit 5387467

Please sign in to comment.