Tweak pause & filament runout

- Check for PausedByFilamentChange flag on pause and resume
- Move stop movements from StateHandler() to StopPrint()
- Retract 1mm on pause (2mm on runout) without feed on resume, preventing ooze
- Fix special menu margin on some buttons
This commit is contained in:
David Ramiro 2019-02-16 18:41:22 +01:00
parent 76b873baee
commit 5fbc1b6035
No known key found for this signature in database
GPG Key ID: 5B042737EBEEB736
1 changed files with 49 additions and 37 deletions

View File

@ -137,10 +137,11 @@ void AnycubicTFTClass::KillTFT()
void AnycubicTFTClass::StartPrint(){ void AnycubicTFTClass::StartPrint(){
if (TFTstate==ANYCUBIC_TFT_STATE_SDPAUSE) { // resuming from SD pause if (TFTstate==ANYCUBIC_TFT_STATE_SDPAUSE) { // resuming from SD pause
if((PausedByRunout==false)) // was that a regular pause? if((PausedByRunout==false) && (PausedByFilamentChange==false)) // was that a regular pause?
{ {
enqueue_and_echo_commands_P(PSTR("G91\nG1 E7 F1800\nG90")); // feed 7mm enqueue_and_echo_commands_P(PSTR("G91")); // relative mode
enqueue_and_echo_commands_P(PSTR("G91\nG1 Z-10 F240\nG90")); // lower nozzle again enqueue_and_echo_commands_P(PSTR("G1 Z-10 F240")); // lower nozzle again
enqueue_and_echo_commands_P(PSTR("G90")); // absolute mode
} }
} }
@ -225,6 +226,30 @@ void AnycubicTFTClass::StopPrint(){
card.stopSDPrint(); card.stopSDPrint();
#endif #endif
clear_command_queue(); clear_command_queue();
if((current_position[Z_AXIS]<150))
{
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z20 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
}
else if ((current_position[Z_AXIS]<190))
{
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z10 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
}
else if ((current_position[Z_AXIS]<200))
{
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z5 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
}
else if ((current_position[Z_AXIS]>=200))
{
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z1 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
}
quickstop_stepper(); quickstop_stepper();
print_job_timer.stop(); print_job_timer.stop();
thermalManager.disable_all_heaters(); thermalManager.disable_all_heaters();
@ -302,12 +327,12 @@ void AnycubicTFTClass::HandleSpecialMenu()
} else if (strcmp(SelectedDirectory, "<z down 0.1>")==0) { } else if (strcmp(SelectedDirectory, "<z down 0.1>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: Z Down 0.1"); SERIAL_PROTOCOLLNPGM("Special Menu: Z Down 0.1");
enqueue_and_echo_commands_P(PSTR("G91\nG1 Z-0.1\nG90")); enqueue_and_echo_commands_P(PSTR("G91\nG1 Z-0.1\nG90"));
} else if (strcmp(SelectedDirectory, "<filament change pause>")==0) { } else if (strcmp(SelectedDirectory, "<filamentchange pause>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: Filament Change Pause"); SERIAL_PROTOCOLLNPGM("Special Menu: FilamentChange Pause");
PausedByFilamentChange=true; PausedByFilamentChange=true;
FilamentChangePause(); FilamentChangePause();
} else if (strcmp(SelectedDirectory, "<filament change resume>")==0) { } else if (strcmp(SelectedDirectory, "<filamentchange resume>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: Filament Change Resume"); SERIAL_PROTOCOLLNPGM("Special Menu: FilamentChange Resume");
FilamentChangeResume(); FilamentChangeResume();
} else if (strcmp(SelectedDirectory, "<exit>")==0) { } else if (strcmp(SelectedDirectory, "<exit>")==0) {
SpecialMenu=false; SpecialMenu=false;
@ -352,10 +377,10 @@ void AnycubicTFTClass::Ls()
break; break;
case 12: // Fourth Page case 12: // Fourth Page
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Pause>"); ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Pause>"); ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Resume>"); ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Resume>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Resume>"); ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Resume>");
break; break;
default: default:
@ -519,18 +544,22 @@ void AnycubicTFTClass::StateHandler()
#ifdef SDSUPPORT #ifdef SDSUPPORT
if((!card.sdprinting) && (!planner.movesplanned())) { if((!card.sdprinting) && (!planner.movesplanned())) {
// We have to wait until the sd card printing has been settled // We have to wait until the sd card printing has been settled
if((PausedByRunout==false)) if((PausedByRunout==false) && (PausedByFilamentChange==false))
{ {
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Regular Pause requested"); SERIAL_ECHOLNPGM("DEBUG: Regular Pause requested");
#endif #endif
enqueue_and_echo_commands_P(PSTR("G91\nG1 E-7 F1800\nG90")); // retract 7mm enqueue_and_echo_commands_P(PSTR("G91")); // relative mode
enqueue_and_echo_commands_P(PSTR("G91\nG1 Z10 F240\nG90")); // lift nozzle enqueue_and_echo_commands_P(PSTR("G1 E-1 F1800")); // retract 1mm
} else { enqueue_and_echo_commands_P(PSTR("G1 Z10 F240")); // lift nozzle by 10mm
enqueue_and_echo_commands_P(PSTR("G91\nG1 E-7 F1800\nG90")); // retract 7mm enqueue_and_echo_commands_P(PSTR("G90")); // absolute mode
enqueue_and_echo_commands_P(PSTR("M300 S1567 P750\nM300 S2093 P750")); } else if((PausedByRunout==true))
enqueue_and_echo_commands_P(PSTR("M300 S1567 P750\nM300 S2093 P750")); {
enqueue_and_echo_commands_P(PSTR("M300 S1567 P750\nM300 S2093 P750")); // alert user with beeps enqueue_and_echo_commands_P(PSTR("G91")); // relative mode
enqueue_and_echo_commands_P(PSTR("G1 E-2 F1800")); // retract 2mm
enqueue_and_echo_commands_P(PSTR("G90")); // absolute mode
enqueue_and_echo_commands_P(PSTR("M300 S1567 P1000")); // alert user with beeps
enqueue_and_echo_commands_P(PSTR("M300 S2093 P3000"));
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Beep-boop"); SERIAL_ECHOLNPGM("DEBUG: Beep-boop");
#endif #endif
@ -560,23 +589,6 @@ void AnycubicTFTClass::StateHandler()
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: SD print stopped... J16"); SERIAL_ECHOLNPGM("TFT Serial Debug: SD print stopped... J16");
#endif #endif
if((current_position[Z_AXIS]<150)) {
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z20 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
} else if ((current_position[Z_AXIS]<190)) {
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z10 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
} else if ((current_position[Z_AXIS]<200)) {
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z5 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
} else if ((current_position[Z_AXIS]>=200)) {
enqueue_and_echo_commands_P(PSTR("G91"));
enqueue_and_echo_commands_P(PSTR("G1 Z1 F240"));
enqueue_and_echo_commands_P(PSTR("G90"));
}
enqueue_and_echo_commands_P(PSTR("M84")); enqueue_and_echo_commands_P(PSTR("M84"));
} }
#endif #endif
@ -809,7 +821,7 @@ void AnycubicTFTClass::GetCommandFromTFT()
case 13: // A13 SELECTION FILE case 13: // A13 SELECTION FILE
#ifdef SDSUPPORT #ifdef SDSUPPORT
//if((!planner.movesplanned()) && (TFTstate!=ANYCUBIC_TFT_STATE_SDPAUSE) && (TFTstate!=ANYCUBIC_TFT_STATE_SDOUTAGE)) //if((!planner.movesplanned()) && (TFTstate!=ANYCUBIC_TFT_STATE_SDPAUSE) && (TFTstate!=ANYCUBIC_TFT_STATE_SDOUTAGE))
if((TFTstate!=ANYCUBIC_TFT_STATE_SDOUTAGE)) if((TFTstate!=ANYCUBIC_TFT_STATE_SDOUTAGE)) // allow special menu to be used while printing from USB
{ {
starpos = (strchr(TFTstrchr_pointer + 4,'*')); starpos = (strchr(TFTstrchr_pointer + 4,'*'));
if (TFTstrchr_pointer[4] == '/') { if (TFTstrchr_pointer[4] == '/') {