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.

M92.cpp 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/planner.h"
  24. void report_M92(const bool echo=true, const int8_t e=-1) {
  25. if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' ');
  26. SERIAL_ECHOPAIR_P(PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]),
  27. SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]),
  28. SP_Z_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]));
  29. #if DISABLED(DISTINCT_E_FACTORS)
  30. SERIAL_ECHOPAIR_P(SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
  31. #endif
  32. SERIAL_EOL();
  33. #if ENABLED(DISTINCT_E_FACTORS)
  34. LOOP_L_N(i, E_STEPPERS) {
  35. if (e >= 0 && i != e) continue;
  36. if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' ');
  37. SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), (int)i,
  38. SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
  39. }
  40. #endif
  41. UNUSED_E(e);
  42. }
  43. /**
  44. * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E.
  45. * (Follows the same syntax as G92)
  46. *
  47. * With multiple extruders use T to specify which one.
  48. *
  49. * If no argument is given print the current values.
  50. *
  51. * With MAGIC_NUMBERS_GCODE:
  52. * Use 'H' and/or 'L' to get ideal layer-height information.
  53. * 'H' specifies micro-steps to use. We guess if it's not supplied.
  54. * 'L' specifies a desired layer height. Nearest good heights are shown.
  55. */
  56. void GcodeSuite::M92() {
  57. const int8_t target_extruder = get_target_extruder_from_command();
  58. if (target_extruder < 0) return;
  59. // No arguments? Show M92 report.
  60. if (!parser.seen("XYZE"
  61. #if ENABLED(MAGIC_NUMBERS_GCODE)
  62. "HL"
  63. #endif
  64. )) return report_M92(true, target_extruder);
  65. LOOP_XYZE(i) {
  66. if (parser.seenval(axis_codes[i])) {
  67. if (i == E_AXIS) {
  68. const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder)));
  69. if (value < 20) {
  70. float factor = planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] / value; // increase e constants if M92 E14 is given for netfab.
  71. #if HAS_CLASSIC_JERK && HAS_CLASSIC_E_JERK
  72. planner.max_jerk.e *= factor;
  73. #endif
  74. planner.settings.max_feedrate_mm_s[E_AXIS_N(target_extruder)] *= factor;
  75. planner.max_acceleration_steps_per_s2[E_AXIS_N(target_extruder)] *= factor;
  76. }
  77. planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] = value;
  78. }
  79. else {
  80. planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i);
  81. }
  82. }
  83. }
  84. planner.refresh_positioning();
  85. #if ENABLED(MAGIC_NUMBERS_GCODE)
  86. #ifndef Z_MICROSTEPS
  87. #define Z_MICROSTEPS 16
  88. #endif
  89. const float wanted = parser.floatval('L');
  90. if (parser.seen('H') || wanted) {
  91. const uint16_t argH = parser.ushortval('H'),
  92. micro_steps = argH ?: Z_MICROSTEPS;
  93. const float z_full_step_mm = micro_steps * planner.steps_to_mm[Z_AXIS];
  94. SERIAL_ECHO_START();
  95. SERIAL_ECHOPAIR("{ micro_steps:", micro_steps, ", z_full_step_mm:", z_full_step_mm);
  96. if (wanted) {
  97. const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm;
  98. SERIAL_ECHOPAIR(", best:[", best);
  99. if (best != wanted) { SERIAL_CHAR(','); SERIAL_ECHO(best + z_full_step_mm); }
  100. SERIAL_CHAR(']');
  101. }
  102. SERIAL_ECHOLNPGM(" }");
  103. }
  104. #endif
  105. }