Skip to content

Commit

Permalink
Add M600 and M108 routines to display code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidramiro committed Feb 15, 2019
1 parent 1fe1842 commit 76b873b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 22 deletions.
58 changes: 45 additions & 13 deletions Marlin/AnycubicTFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ void AnycubicTFTClass::StartPrint(){
}
starttime=millis();
#ifdef SDSUPPORT
if((PausedByRunout==false)) // was that a regular pause?
if((PausedByRunout==false) && (PausedByFilamentChange==false)) // was that a regular pause?
{
card.startFileprint(); // start or resume regularly
}
else // resuming from a pause that was caused by filament runout
else if((PausedByRunout==true) && (PausedByFilamentChange==false)) // 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 @@ -159,6 +159,17 @@ void AnycubicTFTClass::StartPrint(){
PausedByRunout=false; // clear flag
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Filament Pause Flag cleared");
#endif
}
else if((PausedByRunout==false) && (PausedByFilamentChange==true)) // was M600 called?
{
FilamentChangeResume(); // enter M108 routine
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Start M108 routine");
#endif
PausedByFilamentChange=false; // clear flag
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Filament Change Flag cleared");
#endif
}
#endif
Expand Down Expand Up @@ -223,6 +234,25 @@ void AnycubicTFTClass::StopPrint(){
TFTstate=ANYCUBIC_TFT_STATE_SDSTOP_REQ;
}

void AnycubicTFTClass::FilamentChangeResume(){
enqueue_and_echo_commands_P(PSTR("M108")); // call M108 to break out of M600 pause
HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e); // resume heating if timed out
wait_for_heatup = false;
wait_for_user = false; // remove waiting flags
// TFTstate=ANYCUBIC_TFT_STATE_SDPRINT;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: M108 Resume called");
#endif
}

void AnycubicTFTClass::FilamentChangePause(){
enqueue_and_echo_commands_P(PSTR("M600"));
TFTstate=ANYCUBIC_TFT_STATE_SDPAUSE_REQ; // set TFT state to paused
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: M600 Pause called");
#endif
}


float AnycubicTFTClass::CodeValue()
{
Expand Down Expand Up @@ -272,12 +302,13 @@ void AnycubicTFTClass::HandleSpecialMenu()
} else if (strcmp(SelectedDirectory, "<z down 0.1>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: Z Down 0.1");
enqueue_and_echo_commands_P(PSTR("G91\nG1 Z-0.1\nG90"));
} else if (strcmp(SelectedDirectory, "<m600 pause>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: M600 Pause");
enqueue_and_echo_commands_P(PSTR("M600"));
} else if (strcmp(SelectedDirectory, "<m108 resume>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: M108 Resume");
enqueue_and_echo_commands_P(PSTR("M108"));
} else if (strcmp(SelectedDirectory, "<filament change pause>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: Filament Change Pause");
PausedByFilamentChange=true;
FilamentChangePause();
} else if (strcmp(SelectedDirectory, "<filament change resume>")==0) {
SERIAL_PROTOCOLLNPGM("Special Menu: Filament Change Resume");
FilamentChangeResume();
} else if (strcmp(SelectedDirectory, "<exit>")==0) {
SpecialMenu=false;
}
Expand Down Expand Up @@ -321,10 +352,10 @@ void AnycubicTFTClass::Ls()
break;

case 12: // Fourth Page
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<M600 Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<M600 Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<M108 Resume>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<M108 Resume>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Resume>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Filament Change Resume>");
break;

default:
Expand Down Expand Up @@ -777,7 +808,8 @@ void AnycubicTFTClass::GetCommandFromTFT()
break;
case 13: // A13 SELECTION FILE
#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))
{
starpos = (strchr(TFTstrchr_pointer + 4,'*'));
if (TFTstrchr_pointer[4] == '/') {
Expand Down
21 changes: 12 additions & 9 deletions Marlin/AnycubicTFT.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
AnycubicTFT.h --- Support for Anycubic i3 Mega TFT
Created by Christian Hopp on 09.12.17.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Expand Down Expand Up @@ -55,7 +55,7 @@ class AnycubicTFTClass {
void HeatingStart();
void FilamentRunout();
void KillTFT();

private:
char TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE];
int TFTbuflen=0;
Expand All @@ -72,7 +72,9 @@ class AnycubicTFTClass {
uint8_t tmp_extruder=0;
char LastSDstatus=0;
uint16_t HeaterCheckCount=0;

char PausedByRunout=false;
char PausedByFilamentChange=false;

struct OutageDataStruct {
char OutageDataVersion;
char OutageFlag;
Expand All @@ -81,10 +83,10 @@ class AnycubicTFTClass {
float last_hotend_temp;
long lastSDposition;
} OutageData;

void WriteOutageEEPromData();
void ReadOutageEEPromData();

float CodeValue();
bool CodeSeen(char);
void Ls();
Expand All @@ -96,15 +98,16 @@ class AnycubicTFTClass {
void CheckSDCardChange();
void CheckHeaterError();
void HandleSpecialMenu();

void FilamentChangePause();
void FilamentChangeResume();

char SelectedDirectory[30];
uint8_t SpecialMenu=false;

#if ENABLED(ANYCUBIC_FILAMENT_RUNOUT_SENSOR)
char FilamentTestStatus=false;
char FilamentTestLastStatus=false;
long FilamentRunoutCounter=0;
char PausedByRunout=false;
#endif
};

Expand Down

0 comments on commit 76b873b

Please sign in to comment.