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 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../gcode.h"
  23. #include "../../module/motion.h"
  24. #include "../../MarlinCore.h"
  25. #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
  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 xyze_pos_t destination;
  33. #if ENABLED(VARIABLE_G0_FEEDRATE)
  34. feedRate_t fast_move_feedrate = MMM_TO_MMS(G0_FEEDRATE);
  35. #endif
  36. /**
  37. * G0, G1: Coordinated movement of X Y Z E axes
  38. */
  39. void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) {
  40. if (IsRunning()
  41. #if ENABLED(NO_MOTION_BEFORE_HOMING)
  42. && !homing_needed_error(
  43. (parser.seen('X') ? _BV(X_AXIS) : 0)
  44. | (parser.seen('Y') ? _BV(Y_AXIS) : 0)
  45. | (parser.seen('Z') ? _BV(Z_AXIS) : 0) )
  46. #endif
  47. ) {
  48. #ifdef G0_FEEDRATE
  49. feedRate_t old_feedrate;
  50. #if ENABLED(VARIABLE_G0_FEEDRATE)
  51. if (fast_move) {
  52. old_feedrate = feedrate_mm_s; // Back up the (old) motion mode feedrate
  53. feedrate_mm_s = fast_move_feedrate; // Get G0 feedrate from last usage
  54. }
  55. #endif
  56. #endif
  57. get_destination_from_command(); // Get X Y Z E F (and set cutter power)
  58. #ifdef G0_FEEDRATE
  59. if (fast_move) {
  60. #if ENABLED(VARIABLE_G0_FEEDRATE)
  61. fast_move_feedrate = feedrate_mm_s; // Save feedrate for the next G0
  62. #else
  63. old_feedrate = feedrate_mm_s; // Back up the (new) motion mode feedrate
  64. feedrate_mm_s = MMM_TO_MMS(G0_FEEDRATE); // Get the fixed G0 feedrate
  65. #endif
  66. }
  67. #endif
  68. #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
  69. if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
  70. // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves
  71. if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) {
  72. const float echange = destination.e - current_position.e;
  73. // Is this a retract or recover move?
  74. if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
  75. current_position.e = destination.e; // Hide a G1-based retract/recover from calculations
  76. sync_plan_position_e(); // AND from the planner
  77. return fwretract.retract(echange < 0.0); // Firmware-based retract/recover (double-retract ignored)
  78. }
  79. }
  80. }
  81. #endif // FWRETRACT
  82. #if IS_SCARA
  83. fast_move ? prepare_fast_move_to_destination() : prepare_line_to_destination();
  84. #else
  85. prepare_line_to_destination();
  86. #endif
  87. #ifdef G0_FEEDRATE
  88. // Restore the motion mode feedrate
  89. if (fast_move) feedrate_mm_s = old_feedrate;
  90. #endif
  91. #if ENABLED(NANODLP_Z_SYNC)
  92. #if ENABLED(NANODLP_ALL_AXIS)
  93. #define _MOVE_SYNC parser.seenval('X') || parser.seenval('Y') || parser.seenval('Z') // For any move wait and output sync message
  94. #else
  95. #define _MOVE_SYNC parser.seenval('Z') // Only for Z move
  96. #endif
  97. if (_MOVE_SYNC) {
  98. planner.synchronize();
  99. SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP);
  100. }
  101. #endif
  102. }
  103. }