@@ -78,7 +78,8 @@ static void sendLine_P(PGM_P str) {
78
78
79
79
AnycubicMediaPrintState AnycubicTouchscreenClass::mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
80
80
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 ;
82
83
83
84
#if ENABLED(POWER_OUTAGE_TEST)
84
85
int PowerInt = 6 ;
@@ -261,10 +262,13 @@ void AnycubicTouchscreenClass::ResumePrint() {
261
262
262
263
// trigger the user message box
263
264
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 ;
268
272
return ;
269
273
}
270
274
#endif
@@ -1011,8 +1015,12 @@ void AnycubicTouchscreenClass::DoFilamentRunoutCheck() {
1011
1015
// play tone to indicate filament is out
1012
1016
injectCommands (F (" \n M300 P200 S1567\n M300 P200 S1174\n M300 P200 "
1013
1017
" S1567\n M300 P200 S1174\n M300 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 ;
1016
1024
} else {
1017
1025
SENDLINE_DBG_PGM (" J15" , " TFT Serial Debug: Non blocking filament runout... J15" );
1018
1026
}
@@ -1040,29 +1048,49 @@ void AnycubicTouchscreenClass::UserConfirmRequired(const char* const msg) {
1040
1048
if (strcmp_P (msg, PSTR (" Nozzle Parked" )) == 0 ) {
1041
1049
mediaPrintingState = AMPRINTSTATE_PAUSED;
1042
1050
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 ;
1045
1057
} else if (strcmp_P (msg, PSTR (" Load Filament" )) == 0 ) {
1046
1058
mediaPrintingState = AMPRINTSTATE_PAUSED;
1047
1059
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 ;
1051
1067
} else if (strcmp_P (msg, PSTR (" Filament Purging..." )) == 0 ) {
1052
1068
mediaPrintingState = AMPRINTSTATE_PAUSED;
1053
1069
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 ;
1056
1076
} else if (strcmp_P (msg, PSTR (" HeaterTimeout" )) == 0 ) {
1057
1077
mediaPrintingState = AMPRINTSTATE_PAUSED;
1058
1078
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 ;
1061
1085
} else if (strcmp_P (msg, PSTR (" Reheat finished." )) == 0 ) {
1062
1086
mediaPrintingState = AMPRINTSTATE_PAUSED;
1063
1087
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 ;
1066
1094
}
1067
1095
#endif
1068
1096
}
@@ -1288,6 +1316,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
1288
1316
} else {
1289
1317
SEND_PGM_VAL (" A20V " , feedrate_percentage);
1290
1318
SENDLINE_PGM (" " );
1319
+ time_last_cyclic_tft_command = millis ();
1291
1320
}
1292
1321
}
1293
1322
break ;
@@ -2062,6 +2091,29 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
2062
2091
TFTbuflen = (TFTbuflen - 1 );
2063
2092
TFTbufindr = (TFTbufindr + 1 ) % TFTBUFSIZE;
2064
2093
}
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
+ }
2065
2117
}
2066
2118
2067
2119
void AnycubicTouchscreenClass::OnPrintTimerStarted () {
0 commit comments