2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-08 03:33:16 +00:00
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
|
|
|
|
#include "../../Marlin.h"
|
|
|
|
|
2017-09-08 03:40:32 +00:00
|
|
|
#if ENABLED(FWRETRACT)
|
|
|
|
#include "../../feature/fwretract.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 03:33:16 +00:00
|
|
|
#include "../../sd/cardreader.h"
|
|
|
|
|
2017-11-24 20:04:14 +00:00
|
|
|
#if ENABLED(NANODLP_Z_SYNC)
|
|
|
|
#include "../../module/stepper.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 03:33:16 +00:00
|
|
|
extern float destination[XYZE];
|
|
|
|
|
2017-10-31 03:50:22 +00:00
|
|
|
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
|
|
|
#define G0_G1_CONDITION !axis_unhomed_error(parser.seen('X'), parser.seen('Y'), parser.seen('Z'))
|
|
|
|
#else
|
|
|
|
#define G0_G1_CONDITION true
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* G0, G1: Coordinated movement of X Y Z E axes
|
|
|
|
*/
|
2017-09-08 03:33:16 +00:00
|
|
|
void GcodeSuite::G0_G1(
|
2017-09-06 11:28:31 +00:00
|
|
|
#if IS_SCARA
|
2017-09-08 03:33:16 +00:00
|
|
|
bool fast_move/*=false*/
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif
|
|
|
|
) {
|
2017-10-31 03:50:22 +00:00
|
|
|
if (IsRunning() && G0_G1_CONDITION) {
|
2017-09-08 03:33:16 +00:00
|
|
|
get_destination_from_command(); // For X Y Z E F
|
2017-09-06 11:28:31 +00:00
|
|
|
|
|
|
|
#if ENABLED(FWRETRACT)
|
2017-09-08 03:40:32 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
|
|
|
|
// When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves
|
2017-09-08 03:40:32 +00:00
|
|
|
if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) {
|
2017-09-06 11:28:31 +00:00
|
|
|
const float echange = destination[E_AXIS] - current_position[E_AXIS];
|
|
|
|
// Is this a retract or recover move?
|
2017-09-08 03:40:32 +00:00
|
|
|
if (WITHIN(FABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
|
2017-09-06 11:28:31 +00:00
|
|
|
current_position[E_AXIS] = destination[E_AXIS]; // Hide a G1-based retract/recover from calculations
|
|
|
|
sync_plan_position_e(); // AND from the planner
|
2017-09-08 03:40:32 +00:00
|
|
|
return fwretract.retract(echange < 0.0); // Firmware-based retract/recover (double-retract ignored)
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-08 03:40:32 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#endif // FWRETRACT
|
|
|
|
|
|
|
|
#if IS_SCARA
|
|
|
|
fast_move ? prepare_uninterpolated_move_to_destination() : prepare_move_to_destination();
|
|
|
|
#else
|
|
|
|
prepare_move_to_destination();
|
|
|
|
#endif
|
2017-11-24 06:28:06 +00:00
|
|
|
|
|
|
|
#if ENABLED(NANODLP_Z_SYNC)
|
|
|
|
// If G0/G1 command include Z-axis, wait for move and output sync text.
|
|
|
|
if (parser.seenval('Z')) {
|
|
|
|
stepper.synchronize();
|
|
|
|
SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
|
|
|
|
}
|
|
|
|
#endif
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
}
|