Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved robustness of Printing menu during a dialog with Marlin #1898

Closed
wants to merge 14 commits into from
4 changes: 4 additions & 0 deletions TFT/src/User/API/Printing.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ bool printPause(bool isPause, PAUSE_TYPE pauseType)
popupReminder(DIALOG_TYPE_ALERT, LABEL_PAUSE, LABEL_PAUSE);
break;
}

// do not send any command if the pause originated outside TFT
if (pauseType < PAUSE_EXTERNAL)
{
Expand All @@ -484,6 +485,7 @@ bool printPause(bool isPause, PAUSE_TYPE pauseType)
if (isCoorRelative == true) mustStoreCmd("G91\n");
if (isExtrudeRelative == true) mustStoreCmd("M83\n");
}

// store pause type only on pause
infoPrinting.pauseType = pauseType;
}
Expand All @@ -494,6 +496,7 @@ bool printPause(bool isPause, PAUSE_TYPE pauseType)
breakAndContinue(); // clear the queue and send a break and continue
break;
}

// do not send any command if the pause originated outside TFT
if (infoPrinting.pauseType < PAUSE_EXTERNAL)
{
Expand Down Expand Up @@ -569,6 +572,7 @@ void setPrintPause(bool updateHost, PAUSE_TYPE pauseType)
infoPrinting.pause = true;
infoPrinting.pauseType = pauseType;
}

if (updateHost)
infoHost.printing = false;
}
Expand Down
1 change: 0 additions & 1 deletion TFT/src/User/API/Printing.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extern "C" {

#define SUMMARY_NAME_LEN 26 // max character length to copy from name buffer


typedef enum
{
PAUSE_NORMAL = 0,
Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/API/Vfs/vfs.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _VFS_H_
#define _VFS_H_

#include <stdint.h>
#include <stdbool.h>
#include "stdbool.h"
#include "stdint.h"
digant73 marked this conversation as resolved.
Show resolved Hide resolved
#include "ff.h"

#define FOLDER_NUM 255
Expand Down
4 changes: 1 addition & 3 deletions TFT/src/User/API/interfaceCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ void sendQueueCmd(void)
// case the function loopProcess() is invoked by the following function printPause()
Serial_Puts(SERIAL_PORT_2, "ok\n");
purgeLastCmd(avoid_terminal);

printPause(true, PAUSE_NORMAL);
return;
}
Expand All @@ -518,7 +517,6 @@ void sendQueueCmd(void)
// case the function loopProcess() is invoked by the following function printAbort()
Serial_Puts(SERIAL_PORT_2, "ok\n");
purgeLastCmd(avoid_terminal);

printAbort();
return;
}
Expand Down Expand Up @@ -893,7 +891,7 @@ void sendQueueCmd(void)
if (cmd_seen('Z')) setParameter(P_STEALTH_CHOP, STEPPER_INDEX_Z + i, k);

i = (cmd_seen('T')) ? cmd_value() : 0;
if(cmd_seen('E')) setParameter(P_STEALTH_CHOP, STEPPER_INDEX_E0 + i, k);
if (cmd_seen('E')) setParameter(P_STEALTH_CHOP, STEPPER_INDEX_E0 + i, k);
break;
}

Expand Down
13 changes: 11 additions & 2 deletions TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ static const char errorZProbe[] = "ZProbe triggered before move"; // smoothiewa

bool portSeen[_UART_CNT] = {false, false, false, false, false, false};

bool hostDialog = false;

struct HOST_ACTION
{
char prompt_begin[30];
Expand Down Expand Up @@ -258,6 +260,11 @@ void hostActionCommands(void)
}
else if (ack_seen(":paused") || ack_seen(":pause"))
{
if (ack_seen(":paused")) // if paused with ADVANCED_PAUSE_FEATURE enabled in Marlin (:paused),
hostDialog = true; // disable Resume/Pause button in the Printing menu
//else // otherwise, if ADVANCED_PAUSE_FEATURE is disabled in Marlin (:pause),
// hostDialog = false; // enable Resume/Pause button in the Printing menu

// pass value "false" to let Marlin report when the host is not
// printing (when notification ack "Not SD printing" is caught)
setPrintPause(false, PAUSE_EXTERNAL);
Expand All @@ -269,6 +276,8 @@ void hostActionCommands(void)
}
else if (ack_seen(":resumed") || ack_seen(":resume"))
{
hostDialog = false; // enable Resume/Pause button in the Printing menu

// pass value "true" to report the host is printing without waiting
// from Marlin (when notification ack "SD printing byte" is caught)
setPrintResume(true);
Expand Down Expand Up @@ -594,12 +603,12 @@ void parseACK(void)
if (infoMachineSettings.firmwareType != FW_REPRAPFW)
{
// Marlin
fileEndString = " Size:"; // File opened: 1A29A~1.GCO Size: 6974
fileEndString = " Size:"; // File opened: 1A29A~1.GCO Size: 6974
}
else
{
// RRF
ack_seen("result\":\"0:/gcodes/"); // {"key":"job.file.fileName","flags": "","result":"0:/gcodes/pig-4H.gcode"}
ack_seen("result\":\"0:/gcodes/"); // {"key":"job.file.fileName","flags": "","result":"0:/gcodes/pig-4H.gcode"}
fileEndString = "\"";
}
uint16_t start_index = ack_index;
Expand Down
3 changes: 3 additions & 0 deletions TFT/src/User/API/parseACK.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ extern "C" {

#define ACK_MAX_SIZE 512

extern bool hostDialog;

typedef enum // append at the end of this list the id of any new echo message for
{ // which a specific popup message type must be used to notify the user
ECHO_ID_BUSY_PAUSE = 0,
Expand Down Expand Up @@ -37,6 +39,7 @@ void setCurrentAckSrc(uint8_t src);
void parseACK(void);
void parseRcvGcode(void);

inline bool isHostDialog() {return hostDialog;}
void setIgnoreEcho(ECHO_ID msgId, bool state);

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@

// Axes names displayed in Parameter Settings menu
#define AXIS_DISPLAY_ID {"X", "Y", "Z", "E0", "E1"} // (X, Y, Z, E0, E1)
#define STEPPER_DISPLAY_ID {"X", "X2", "Y", "Y2", "Z", "Z2", "E0", "E1"} // (X, X2, Y, Y2, Z, Z2, E0, E1)
#define STEPPER_DISPLAY_ID {"X", "X2", "Y", "Y2", "Z", "Z2", "E0", "E1"} // (X, X2, Y, Y2, Z, Z2, E0, E1)

// Default X & Y speed (mm/min)
#define SPEED_XY_SLOW 1000
Expand Down
8 changes: 5 additions & 3 deletions TFT/src/User/Menu/PrintingMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ static inline void reDrawSpeed(int icon_pos)
GUI_SetTextMode(GUI_TEXTMODE_NORMAL);
}


static inline void reDrawProgress(int icon_pos, uint8_t prevProgress)
{
char progress[6];
Expand Down Expand Up @@ -394,7 +393,7 @@ void menuPrinting(void)

while (infoMenu.menu[infoMenu.cur] == menuPrinting)
{
//Scroll_DispString(&titleScroll, LEFT); // Scroll display file name will take too many CPU cycles
//Scroll_DispString(&titleScroll, LEFT); // Scroll display file name will take too many CPU cycles

// check nozzle temp change
if (nowHeat.T[currentTool].current != heatGetCurrentTemp(currentTool) ||
Expand Down Expand Up @@ -485,7 +484,10 @@ void menuPrinting(void)
case KEY_ICON_4:
if (isPrinting())
{
printPause(!isPaused(), PAUSE_NORMAL);
if (!isHostDialog())
printPause(!isPaused(), PAUSE_NORMAL);
else
addToast(DIALOG_TYPE_ERROR, (char *)textSelect(LABEL_BUSY));
}
#ifndef TFT70_V3_0
else
Expand Down
9 changes: 5 additions & 4 deletions TFT/src/User/Menu/SettingsMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void menuInfo(void)

// GUI_HLine(0, clocks[5].y + BYTE_HEIGHT, LCD_WIDTH);

//spi flash info
// spi flash info
float usedMB = (float)FLASH_USED/1048576;
sprintf(buf, "Used %.2f%% (%.2fMB/%uMB)", flashUsedPercentage(), usedMB, (W25Qxx_ReadCapacity()/1048576));

Expand All @@ -124,8 +124,9 @@ void menuInfo(void)
{start_x, top_y + 6*BYTE_HEIGHT, LCD_WIDTH, top_y + 7*BYTE_HEIGHT},
{start_x, top_y + 7*BYTE_HEIGHT, LCD_WIDTH, top_y + 8*BYTE_HEIGHT},
{start_x, top_y + 8*BYTE_HEIGHT, LCD_WIDTH, top_y + 9*BYTE_HEIGHT},
};
//draw titles
};

// draw titles
GUI_DispString(0, version[0].y0, (uint8_t *)"System :");
GUI_DispString(0, version[1].y0, (uint8_t *)"Machine :");
GUI_DispString(0, version[2].y0, (uint8_t *)"Board :");
Expand All @@ -137,7 +138,7 @@ void menuInfo(void)
GUI_DispString(0, version[6].y0, (uint8_t *)"IP :");
}

//draw info
// draw info
GUI_SetColor(0xDB40);
GUI_DispStringInPrectEOL(&version[0], firmare_name);
GUI_DispStringInPrectEOL(&version[1], machine_type);
Expand Down