Skip to content

Commit

Permalink
Pause & runout code cleanup
Browse files Browse the repository at this point in the history
Final changes to pause & filament runout overhaul before release:
- Use booleans instead of chars for cleaner code
- Raised retraction amount
  • Loading branch information
davidramiro committed Feb 18, 2019
1 parent 16d6d37 commit 2bd6f2f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions Marlin/AnycubicTFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Marlin/AnycubicTFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class AnycubicTFTClass {
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;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2bd6f2f

Please sign in to comment.