Add automatic filament change function with touchscreen controls.

This commit is contained in:
Knutwurst
2020-06-05 08:30:14 +02:00
parent fa20afc047
commit bbd2b97133

View File

@@ -29,6 +29,11 @@
#include "../../../module/motion.h"
#include "../../../module/printcounter.h"
#ifdef ANYCUBIC_TOUCHSCREEN
#include "../../../lcd/anycubic_touchscreen.h"
#include "../../../sd/cardreader.h"
#endif
#if EXTRUDERS > 1
#include "../../../module/tool_change.h"
#endif
@@ -59,27 +64,57 @@
*
* Default values are used for omitted arguments.
*/
void GcodeSuite::M600() {
void GcodeSuite::M600()
{
#ifdef ANYCUBIC_TOUCHSCREEN
#ifdef SDSUPPORT
if (card.isPrinting())
{ // are we printing from sd?
if (AnycubicTouchscreen.ai3m_pause_state < 2)
{
AnycubicTouchscreen.ai3m_pause_state = 2;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPAIR(" DEBUG: M600 - AI3M Pause State set to: ", AnycubicTouchscreen.ai3m_pause_state);
SERIAL_EOL();
#endif
}
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Enter M600 TFTstate routine");
#endif
AnycubicTouchscreen.TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE_REQ; // enter correct display state to show resume button
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Set TFTstate to SDPAUSE_REQ");
#endif
}
#endif
#endif
xyz_pos_t park_point = NOZZLE_PARK_POINT;
#if ENABLED(MIXING_EXTRUDER)
const int8_t target_e_stepper = get_target_e_stepper_from_command();
if (target_e_stepper < 0) return;
if (target_e_stepper < 0)
return;
const uint8_t old_mixing_tool = mixer.get_current_vtool();
mixer.T(MIXER_DIRECT_SET_TOOL);
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0);
MIXER_STEPPER_LOOP(i)
mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0);
mixer.normalize();
const int8_t target_extruder = active_extruder;
#else
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
if (target_extruder < 0)
return;
#endif
#if ENABLED(DUAL_X_CARRIAGE)
int8_t DXC_ext = target_extruder;
if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
if (!parser.seen('T'))
{ // If no tool index is specified, M600 was (probably) sent in response to filament runout.
// In this case, for duplicating modes set DXC_ext to the extruder that ran out.
#if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
if (dxc_is_duplicating())
@@ -97,7 +132,8 @@ void GcodeSuite::M600() {
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
// Don't allow filament change without homing first
if (axes_need_homing()) home_all_axes();
if (axes_need_homing())
home_all_axes();
#endif
#if EXTRUDERS > 1
@@ -108,7 +144,8 @@ void GcodeSuite::M600() {
#if ENABLED(DUAL_X_CARRIAGE)
&& dual_x_carriage_mode != DXC_DUPLICATION_MODE && dual_x_carriage_mode != DXC_MIRRORED_MODE
#endif
) tool_change(target_extruder, false);
)
tool_change(target_extruder, false);
#endif
// Initial retract before move to filament change position
@@ -118,14 +155,15 @@ void GcodeSuite::M600() {
#endif
);
xyz_pos_t park_point NOZZLE_PARK_POINT;
// Lift Z axis
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
if (parser.seenval('Z'))
park_point.z = parser.linearval('Z');
// Move XY axes to filament change position or given position
if (parser.seenval('X')) park_point.x = parser.linearval('X');
if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
if (parser.seenval('X'))
park_point.x = parser.linearval('X');
if (parser.seenval('Y'))
park_point.y = parser.linearval('Y');
#if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA)
park_point += hotend_offset[active_extruder];
@@ -157,7 +195,8 @@ void GcodeSuite::M600() {
#endif
);
if (pause_print(retract, park_point, unload_length, true DXC_PASS)) {
if (pause_print(retract, park_point, unload_length, true DXC_PASS))
{
#if ENABLED(MMU2_MENUS)
mmu2_M600();
resume_print(slow_load_length, fast_load_length, 0, beep_count DXC_PASS);