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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 <http://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(
  40. #if IS_SCARA || defined(G0_FEEDRATE)
  41. const bool fast_move/*=false*/
  42. #endif
  43. ) {
  44. if (IsRunning()
  45. #if ENABLED(NO_MOTION_BEFORE_HOMING)
  46. && !axis_unhomed_error(
  47. (parser.seen('X') ? _BV(X_AXIS) : 0)
  48. | (parser.seen('Y') ? _BV(Y_AXIS) : 0)
  49. | (parser.seen('Z') ? _BV(Z_AXIS) : 0) )
  50. #endif
  51. ) {
  52. #ifdef G0_FEEDRATE
  53. feedRate_t old_feedrate;
  54. #if ENABLED(VARIABLE_G0_FEEDRATE)
  55. if (fast_move) {
  56. old_feedrate = feedrate_mm_s; // Back up the (old) motion mode feedrate
  57. feedrate_mm_s = fast_move_feedrate; // Get G0 feedrate from last usage
  58. }
  59. #endif
  60. #endif
  61. get_destination_from_command(); // Process X Y Z E F parameters
  62. #ifdef G0_FEEDRATE
  63. if (fast_move) {
  64. #if ENABLED(VARIABLE_G0_FEEDRATE)
  65. fast_move_feedrate = feedrate_mm_s; // Save feedrate for the next G0
  66. #else
  67. old_feedrate = feedrate_mm_s; // Back up the (new) motion mode feedrate
  68. feedrate_mm_s = MMM_TO_MMS(G0_FEEDRATE); // Get the fixed G0 feedrate
  69. #endif
  70. }
  71. #endif
  72. #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
  73. if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
  74. // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves
  75. if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) {
  76. const float echange = destination.e - current_position.e;
  77. // Is this a retract or recover move?
  78. if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
  79. current_position.e = destination.e; // Hide a G1-based retract/recover from calculations
  80. sync_plan_position_e(); // AND from the planner
  81. return fwretract.retract(echange < 0.0); // Firmware-based retract/recover (double-retract ignored)
  82. }
  83. }
  84. }
  85. #endif // FWRETRACT
  86. #if IS_SCARA
  87. fast_move ? prepare_fast_move_to_destination() : prepare_line_to_destination();
  88. #else
  89. prepare_line_to_destination();
  90. #endif
  91. #ifdef G0_FEEDRATE
  92. // Restore the motion mode feedrate
  93. if (fast_move) feedrate_mm_s = old_feedrate;
  94. #endif
  95. #if ENABLED(NANODLP_Z_SYNC)
  96. #if ENABLED(NANODLP_ALL_AXIS)
  97. #define _MOVE_SYNC parser.seenval('X') || parser.seenval('Y') || parser.seenval('Z') // For any move wait and output sync message
  98. #else
  99. #define _MOVE_SYNC parser.seenval('Z') // Only for Z move
  100. #endif
  101. if (_MOVE_SYNC) {
  102. planner.synchronize();
  103. SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP);
  104. }
  105. #endif
  106. }
  107. }