From 2bd6f2f23a49fd4966d4a932bd94a75420d2dae4 Mon Sep 17 00:00:00 2001 From: David Ramiro Date: Mon, 18 Feb 2019 18:05:37 +0100 Subject: [PATCH] Pause & runout code cleanup Final changes to pause & filament runout overhaul before release: - Use booleans instead of chars for cleaner code - Raised retraction amount --- Marlin/AnycubicTFT.cpp | 24 ++++++++++++------------ Marlin/AnycubicTFT.h | 4 ++-- Marlin/Version.h | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Marlin/AnycubicTFT.cpp b/Marlin/AnycubicTFT.cpp index 04589a2..0c298be 100644 --- a/Marlin/AnycubicTFT.cpp +++ b/Marlin/AnycubicTFT.cpp @@ -137,7 +137,7 @@ void AnycubicTFTClass::KillTFT() void AnycubicTFTClass::StartPrint(){ if (TFTstate==ANYCUBIC_TFT_STATE_SDPAUSE) { // resuming from SD pause - if((PausedByRunout==false) && (PausedByFilamentChange==false)) // was that a regular pause? + if((!PausedByRunout) && (!PausedByFilamentChange)) // was that a regular pause? { enqueue_and_echo_commands_P(PSTR("G91")); // relative mode enqueue_and_echo_commands_P(PSTR("G1 Z-10 F240")); // lower nozzle again @@ -147,11 +147,11 @@ void AnycubicTFTClass::StartPrint(){ } starttime=millis(); #ifdef SDSUPPORT - if((PausedByRunout==false) && (PausedByFilamentChange==false)) // was that a regular pause? + if((!PausedByRunout) && (!PausedByFilamentChange)) // was that a regular pause? { card.startFileprint(); // start or resume regularly } - else if((PausedByRunout==true) && (PausedByFilamentChange==false)) // resuming from a pause that was caused by filament runout + else if((PausedByRunout) && (!PausedByFilamentChange)) // resuming from a pause that was caused by filament runout { enqueue_and_echo_commands_P(PSTR("M24")); // unpark nozzle and resume #ifdef ANYCUBIC_TFT_DEBUG @@ -162,7 +162,7 @@ void AnycubicTFTClass::StartPrint(){ SERIAL_ECHOLNPGM("DEBUG: Filament Pause Flag cleared"); #endif } - else if((PausedByRunout==false) && (PausedByFilamentChange==true)) // was M600 called? + else if((!PausedByRunout) && (PausedByFilamentChange)) // was M600 called? { FilamentChangeResume(); // enter M108 routine #ifdef ANYCUBIC_TFT_DEBUG @@ -179,7 +179,7 @@ void AnycubicTFTClass::StartPrint(){ void AnycubicTFTClass::PausePrint(){ #ifdef SDSUPPORT - if((PausedByRunout==false)) // is this a regular pause? + if((!PausedByRunout)) // is this a regular pause? { card.pauseSDPrint(); // pause print regularly #ifdef ANYCUBIC_TFT_DEBUG @@ -195,10 +195,10 @@ void AnycubicTFTClass::PausePrint(){ #ifdef ANYCUBIC_TFT_DEBUG SERIAL_ECHOLNPGM("DEBUG: M25 sent, parking nozzle"); #endif - ANYCUBIC_SERIAL_PROTOCOLPGM("J23"); //J23 FILAMENT LACK with the prompt box don't disappear + ANYCUBIC_SERIAL_PROTOCOLPGM("J23"); //J23 Show Filament Lack prompt on screen ANYCUBIC_SERIAL_ENTER(); #ifdef ANYCUBIC_TFT_DEBUG - SERIAL_ECHOLNPGM("DEBUG: J23 OOF prompt"); + SERIAL_ECHOLNPGM("DEBUG: J23 Show filament prompt"); #endif } #endif @@ -544,24 +544,24 @@ void AnycubicTFTClass::StateHandler() #ifdef SDSUPPORT if((!card.sdprinting) && (!planner.movesplanned())) { // We have to wait until the sd card printing has been settled - if((PausedByRunout==false) && (PausedByFilamentChange==false)) + if((!PausedByRunout) && (!PausedByFilamentChange)) { #ifdef ANYCUBIC_TFT_DEBUG SERIAL_ECHOLNPGM("DEBUG: Regular Pause requested"); #endif enqueue_and_echo_commands_P(PSTR("G91")); // relative mode - enqueue_and_echo_commands_P(PSTR("G1 E-1 F1800")); // retract 1mm + enqueue_and_echo_commands_P(PSTR("G1 E-2 F1800")); // retract 2mm enqueue_and_echo_commands_P(PSTR("G1 Z10 F240")); // lift nozzle by 10mm enqueue_and_echo_commands_P(PSTR("G90")); // absolute mode - } else if((PausedByRunout==true)) + } else if((PausedByRunout)) { 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("G1 E-3 F1800")); // retract 3mm 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 - SERIAL_ECHOLNPGM("DEBUG: Beep-boop"); + SERIAL_ECHOLNPGM("DEBUG: Filament runout - Retract, beep and park."); #endif } #ifdef ANYCUBIC_FILAMENT_RUNOUT_SENSOR diff --git a/Marlin/AnycubicTFT.h b/Marlin/AnycubicTFT.h index 6f2a8fc..ccc465b 100644 --- a/Marlin/AnycubicTFT.h +++ b/Marlin/AnycubicTFT.h @@ -72,8 +72,8 @@ private: uint8_t tmp_extruder=0; char LastSDstatus=0; uint16_t HeaterCheckCount=0; - char PausedByRunout=false; - char PausedByFilamentChange=false; + bool PausedByRunout=false; + bool PausedByFilamentChange=false; struct OutageDataStruct { char OutageDataVersion; diff --git a/Marlin/Version.h b/Marlin/Version.h index 28f62c8..29669ef 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -48,7 +48,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ - #define STRING_DISTRIBUTION_DATE "2019-02-11" + #define STRING_DISTRIBUTION_DATE "2019-02-18" /** * Required minimum Configuration.h and Configuration_adv.h file versions.