My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

G0_G1.cpp 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../gcode.h"
  23. #include "../../module/motion.h"
  24. #include "../../Marlin.h"
  25. #if ENABLED(FWRETRACT)
  26. #include "../../feature/fwretract.h"
  27. #endif
  28. #include "../../sd/cardreader.h"
  29. #if ENABLED(NANODLP_Z_SYNC)
  30. #include "../../module/stepper.h"
  31. #endif
  32. extern float destination[XYZE];
  33. #if ENABLED(NO_MOTION_BEFORE_HOMING)
  34. #define G0_G1_CONDITION !axis_unhomed_error(parser.seen('X'), parser.seen('Y'), parser.seen('Z'))
  35. #else
  36. #define G0_G1_CONDITION true
  37. #endif
  38. /**
  39. * G0, G1: Coordinated movement of X Y Z E axes
  40. */
  41. void GcodeSuite::G0_G1(
  42. #if IS_SCARA
  43. bool fast_move/*=false*/
  44. #endif
  45. ) {
  46. if (IsRunning() && G0_G1_CONDITION) {
  47. get_destination_from_command(); // For X Y Z E F
  48. #if ENABLED(FWRETRACT)
  49. if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
  50. // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves
  51. if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) {
  52. const float echange = destination[E_AXIS] - current_position[E_AXIS];
  53. // Is this a retract or recover move?
  54. if (WITHIN(FABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
  55. current_position[E_AXIS] = destination[E_AXIS]; // Hide a G1-based retract/recover from calculations
  56. sync_plan_position_e(); // AND from the planner
  57. return fwretract.retract(echange < 0.0); // Firmware-based retract/recover (double-retract ignored)
  58. }
  59. }
  60. }
  61. #endif // FWRETRACT
  62. #if IS_SCARA
  63. fast_move ? prepare_uninterpolated_move_to_destination() : prepare_move_to_destination();
  64. #else
  65. prepare_move_to_destination();
  66. #endif
  67. #if ENABLED(NANODLP_Z_SYNC)
  68. #if ENABLED(NANODLP_ALL_AXIS)
  69. #define _MOVE_SYNC true // For any move wait and output sync message
  70. #else
  71. #define _MOVE_SYNC parser.seenval('Z') // Only for Z move
  72. #endif
  73. if (_MOVE_SYNC) {
  74. stepper.synchronize();
  75. SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
  76. }
  77. #endif
  78. }
  79. }