Skip to content

Commit a34fa2f

Browse files
author
core.editor
committed
fix against too fast sending acycling display command
Anycubic 1.0 display ignores acyclic telegrams as J23 or J18 if they are sent too fast after last cyclic telegram. This results for the user in sporadic not occuring mask "Lack of filament..." or no continue button at filament sensor or M600 G-Code command. The last issue is catatrophic for the print job because interrupted at this point. This commit fix the problem by integrating a minimum time delay which was seen at original anycubic i3 mega S fw.
1 parent 09e49ea commit a34fa2f

File tree

2 files changed

+73
-18
lines changed

2 files changed

+73
-18
lines changed

Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp

+70-18
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ static void sendLine_P(PGM_P str) {
7878

7979
AnycubicMediaPrintState AnycubicTouchscreenClass::mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
8080
AnycubicMediaPauseState AnycubicTouchscreenClass::mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
81-
81+
uint32_t AnycubicTouchscreenClass::time_last_cyclic_tft_command = 0;
82+
uint8_t AnycubicTouchscreenClass::delayed_tft_command = 0;
8283

8384
#if ENABLED(POWER_OUTAGE_TEST)
8485
int PowerInt = 6;
@@ -261,10 +262,13 @@ void AnycubicTouchscreenClass::ResumePrint() {
261262

262263
// trigger the user message box
263264
DoFilamentRunoutCheck();
264-
265-
// re-enable the continue button
266-
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: Resume Print with filament sensor still "
267-
"tripped... J18");
265+
if ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) {
266+
// re-enable the continue button
267+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: Resume Print with filament sensor still "
268+
"tripped... J18");
269+
}
270+
else
271+
delayed_tft_command = 18;
268272
return;
269273
}
270274
#endif
@@ -1011,8 +1015,12 @@ void AnycubicTouchscreenClass::DoFilamentRunoutCheck() {
10111015
// play tone to indicate filament is out
10121016
injectCommands(F("\nM300 P200 S1567\nM300 P200 S1174\nM300 P200 "
10131017
"S1567\nM300 P200 S1174\nM300 P2000 S1567"));
1014-
// tell the user that the filament has run out and wait
1015-
SENDLINE_DBG_PGM("J23", "TFT Serial Debug: Blocking filament prompt... J23");
1018+
if ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) {
1019+
// tell the user that the filament has run out and wait
1020+
SENDLINE_DBG_PGM("J23", "TFT Serial Debug: Blocking filament prompt... J23");
1021+
}
1022+
else
1023+
delayed_tft_command = 23;
10161024
} else {
10171025
SENDLINE_DBG_PGM("J15", "TFT Serial Debug: Non blocking filament runout... J15");
10181026
}
@@ -1040,29 +1048,49 @@ void AnycubicTouchscreenClass::UserConfirmRequired(const char* const msg) {
10401048
if (strcmp_P(msg, PSTR("Nozzle Parked")) == 0) {
10411049
mediaPrintingState = AMPRINTSTATE_PAUSED;
10421050
mediaPauseState = AMPAUSESTATE_PARKED;
1043-
// enable continue button
1044-
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm SD print paused done... J18");
1051+
if ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) {
1052+
// enable continue button
1053+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm SD print paused done... J18");
1054+
}
1055+
else
1056+
delayed_tft_command = 18;
10451057
} else if (strcmp_P(msg, PSTR("Load Filament")) == 0) {
10461058
mediaPrintingState = AMPRINTSTATE_PAUSED;
10471059
mediaPauseState = AMPAUSESTATE_FILAMENT_OUT;
1048-
// enable continue button
1049-
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm Filament is out... J18");
1050-
SENDLINE_DBG_PGM("J23", "TFT Serial Debug: UserConfirm Blocking filament prompt... J23");
1060+
if ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) {
1061+
// enable continue button
1062+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm Filament is out... J18");
1063+
SENDLINE_DBG_PGM("J23", "TFT Serial Debug: UserConfirm Blocking filament prompt... J23");
1064+
}
1065+
else
1066+
delayed_tft_command = 118;
10511067
} else if (strcmp_P(msg, PSTR("Filament Purging...")) == 0) {
10521068
mediaPrintingState = AMPRINTSTATE_PAUSED;
10531069
mediaPauseState = AMPAUSESTATE_FILAMENT_PURGING;
1054-
// enable continue button
1055-
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm Filament is purging... J18");
1070+
if ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) {
1071+
// enable continue button
1072+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm Filament is purging... J18");
1073+
}
1074+
else
1075+
delayed_tft_command = 18;
10561076
} else if (strcmp_P(msg, PSTR("HeaterTimeout")) == 0) {
10571077
mediaPrintingState = AMPRINTSTATE_PAUSED;
10581078
mediaPauseState = AMPAUSESTATE_HEATER_TIMEOUT;
1059-
// enable continue button
1060-
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm SD Heater timeout... J18");
1079+
if ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) {
1080+
// enable continue button
1081+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm SD Heater timeout... J18");
1082+
}
1083+
else
1084+
delayed_tft_command = 18;
10611085
} else if (strcmp_P(msg, PSTR("Reheat finished.")) == 0) {
10621086
mediaPrintingState = AMPRINTSTATE_PAUSED;
10631087
mediaPauseState = AMPAUSESTATE_REHEAT_FINISHED;
1064-
// enable continue button
1065-
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm SD Reheat done... J18");
1088+
if ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) {
1089+
// enable continue button
1090+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: UserConfirm SD Reheat done... J18");
1091+
}
1092+
else
1093+
delayed_tft_command = 18;
10661094
}
10671095
#endif
10681096
}
@@ -1288,6 +1316,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
12881316
} else {
12891317
SEND_PGM_VAL("A20V ", feedrate_percentage);
12901318
SENDLINE_PGM("");
1319+
time_last_cyclic_tft_command = millis();
12911320
}
12921321
}
12931322
break;
@@ -2062,6 +2091,29 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
20622091
TFTbuflen = (TFTbuflen - 1);
20632092
TFTbufindr = (TFTbufindr + 1) % TFTBUFSIZE;
20642093
}
2094+
2095+
// In case of too short time after last cyclic tft command it has to be
2096+
// wait to avoid missing action after acyclic command by the tft.
2097+
if ( (delayed_tft_command > 0) && ( millis() - time_last_cyclic_tft_command >= WAIT_MS_UNTIL_ACYCLIC_SEND ) ) {
2098+
switch (delayed_tft_command) {
2099+
case 23: {
2100+
SENDLINE_DBG_PGM("J23", "TFT Serial Debug: delayed J23");
2101+
delayed_tft_command = 0;
2102+
break;
2103+
}
2104+
case 18: {
2105+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: delayed J18");
2106+
delayed_tft_command = 0;
2107+
break;
2108+
}
2109+
case 118: {
2110+
SENDLINE_DBG_PGM("J23", "TFT Serial Debug: delayed J23");
2111+
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: delayed J18");
2112+
delayed_tft_command = 0;
2113+
break;
2114+
}
2115+
}
2116+
}
20652117
}
20662118

20672119
void AnycubicTouchscreenClass::OnPrintTimerStarted() {

Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ enum AnycubicMediaPauseState {
138138
#define SM_BLTZ_EXIT_L "<SAVE and EXIT>"
139139
#define SM_HS_DISABLE_L "<Disable HiSpeed Mode>"
140140
#define SM_HS_ENABLE_L "<Enable HiSpeed Mode>"
141+
#define WAIT_MS_UNTIL_ACYCLIC_SEND 500
141142
#endif // !KNUTWURST_DGUS2_TFT
142143

143144
#if ENABLED(KNUTWURST_DGUS2_TFT)
@@ -228,6 +229,8 @@ class AnycubicTouchscreenClass {
228229

229230
static AnycubicMediaPrintState mediaPrintingState;
230231
static AnycubicMediaPauseState mediaPauseState;
232+
static uint32_t time_last_cyclic_tft_command;
233+
static uint8_t delayed_tft_command;
231234

232235
#if defined(POWER_OUTAGE_TEST)
233236
struct OutageDataStruct {

0 commit comments

Comments
 (0)