2017-09-06 06:28:31 -05:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 08:00:57 -06:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-27 23:57:50 -05:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
* 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-07 22:33:16 -05:00
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
|
2020-01-02 19:01:38 -06:00
|
|
|
#include "../../MarlinCore.h"
|
2017-09-07 22:33:16 -05:00
|
|
|
|
2019-03-16 23:43:06 -05:00
|
|
|
#if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
|
2017-09-07 22:40:32 -05:00
|
|
|
#include "../../feature/fwretract.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-07 22:33:16 -05:00
|
|
|
#include "../../sd/cardreader.h"
|
|
|
|
|
2017-11-24 14:04:14 -06:00
|
|
|
#if ENABLED(NANODLP_Z_SYNC)
|
|
|
|
#include "../../module/stepper.h"
|
|
|
|
#endif
|
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
extern xyze_pos_t destination;
|
2017-09-07 22:33:16 -05:00
|
|
|
|
2018-10-25 10:35:16 -05:00
|
|
|
#if ENABLED(VARIABLE_G0_FEEDRATE)
|
2019-09-26 01:28:09 -05:00
|
|
|
feedRate_t fast_move_feedrate = MMM_TO_MMS(G0_FEEDRATE);
|
2017-10-30 22:50:22 -05:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 06:28:31 -05:00
|
|
|
/**
|
|
|
|
* G0, G1: Coordinated movement of X Y Z E axes
|
|
|
|
*/
|
2017-09-07 22:33:16 -05:00
|
|
|
void GcodeSuite::G0_G1(
|
2018-10-25 10:35:16 -05:00
|
|
|
#if IS_SCARA || defined(G0_FEEDRATE)
|
2019-09-26 01:28:09 -05:00
|
|
|
const bool fast_move/*=false*/
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
|
|
|
) {
|
2018-10-16 02:02:20 -05:00
|
|
|
|
2018-10-25 10:35:16 -05:00
|
|
|
if (IsRunning()
|
|
|
|
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
2019-09-25 21:01:29 -05:00
|
|
|
&& !axis_unhomed_error(
|
|
|
|
(parser.seen('X') ? _BV(X_AXIS) : 0)
|
|
|
|
| (parser.seen('Y') ? _BV(Y_AXIS) : 0)
|
|
|
|
| (parser.seen('Z') ? _BV(Z_AXIS) : 0) )
|
2018-10-25 10:35:16 -05:00
|
|
|
#endif
|
|
|
|
) {
|
|
|
|
|
|
|
|
#ifdef G0_FEEDRATE
|
2019-09-26 01:28:09 -05:00
|
|
|
feedRate_t old_feedrate;
|
2018-10-25 10:35:16 -05:00
|
|
|
#if ENABLED(VARIABLE_G0_FEEDRATE)
|
|
|
|
if (fast_move) {
|
2019-09-26 01:28:09 -05:00
|
|
|
old_feedrate = feedrate_mm_s; // Back up the (old) motion mode feedrate
|
|
|
|
feedrate_mm_s = fast_move_feedrate; // Get G0 feedrate from last usage
|
2018-10-25 10:35:16 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
2018-10-16 02:02:20 -05:00
|
|
|
|
2019-09-26 01:28:09 -05:00
|
|
|
get_destination_from_command(); // Process X Y Z E F parameters
|
2018-10-25 10:35:16 -05:00
|
|
|
|
|
|
|
#ifdef G0_FEEDRATE
|
2018-10-16 01:49:51 -05:00
|
|
|
if (fast_move) {
|
2018-10-25 10:35:16 -05:00
|
|
|
#if ENABLED(VARIABLE_G0_FEEDRATE)
|
2019-09-26 01:28:09 -05:00
|
|
|
fast_move_feedrate = feedrate_mm_s; // Save feedrate for the next G0
|
2018-10-25 10:35:16 -05:00
|
|
|
#else
|
2019-09-26 01:28:09 -05:00
|
|
|
old_feedrate = feedrate_mm_s; // Back up the (new) motion mode feedrate
|
2018-10-25 10:35:16 -05:00
|
|
|
feedrate_mm_s = MMM_TO_MMS(G0_FEEDRATE); // Get the fixed G0 feedrate
|
|
|
|
#endif
|
2018-10-16 01:49:51 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-03-16 23:43:06 -05:00
|
|
|
#if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
|
2017-09-07 22:40:32 -05:00
|
|
|
|
2017-09-06 06:28:31 -05:00
|
|
|
if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
|
|
|
|
// When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves
|
2017-09-07 22:40:32 -05:00
|
|
|
if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) {
|
2019-09-29 04:25:39 -05:00
|
|
|
const float echange = destination.e - current_position.e;
|
2017-09-06 06:28:31 -05:00
|
|
|
// Is this a retract or recover move?
|
2018-05-13 01:10:34 -05:00
|
|
|
if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
|
2019-09-29 04:25:39 -05:00
|
|
|
current_position.e = destination.e; // Hide a G1-based retract/recover from calculations
|
|
|
|
sync_plan_position_e(); // AND from the planner
|
|
|
|
return fwretract.retract(echange < 0.0); // Firmware-based retract/recover (double-retract ignored)
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-07 22:40:32 -05:00
|
|
|
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif // FWRETRACT
|
|
|
|
|
|
|
|
#if IS_SCARA
|
2019-09-26 01:28:09 -05:00
|
|
|
fast_move ? prepare_fast_move_to_destination() : prepare_move_to_destination();
|
2017-09-06 06:28:31 -05:00
|
|
|
#else
|
|
|
|
prepare_move_to_destination();
|
|
|
|
#endif
|
2017-11-24 00:28:06 -06:00
|
|
|
|
2018-10-25 10:35:16 -05:00
|
|
|
#ifdef G0_FEEDRATE
|
|
|
|
// Restore the motion mode feedrate
|
2019-09-26 01:28:09 -05:00
|
|
|
if (fast_move) feedrate_mm_s = old_feedrate;
|
2018-10-16 01:49:51 -05:00
|
|
|
#endif
|
2018-10-16 02:02:20 -05:00
|
|
|
|
2017-11-24 00:28:06 -06:00
|
|
|
#if ENABLED(NANODLP_Z_SYNC)
|
2017-12-15 13:34:41 -06:00
|
|
|
#if ENABLED(NANODLP_ALL_AXIS)
|
2018-03-28 13:03:34 -05:00
|
|
|
#define _MOVE_SYNC parser.seenval('X') || parser.seenval('Y') || parser.seenval('Z') // For any move wait and output sync message
|
2017-12-15 13:34:41 -06:00
|
|
|
#else
|
|
|
|
#define _MOVE_SYNC parser.seenval('Z') // Only for Z move
|
|
|
|
#endif
|
|
|
|
if (_MOVE_SYNC) {
|
2018-05-12 01:38:02 -05:00
|
|
|
planner.synchronize();
|
2020-02-26 03:02:03 -06:00
|
|
|
SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP);
|
2017-11-24 00:28:06 -06:00
|
|
|
}
|
|
|
|
#endif
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
}
|