My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

M852.cpp 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 "../../inc/MarlinConfig.h"
  23. #if ENABLED(SKEW_CORRECTION_GCODE)
  24. #include "../gcode.h"
  25. #include "../../module/planner.h"
  26. /**
  27. * M852: Get or set the machine skew factors. Reports current values with no arguments.
  28. *
  29. * S[xy_factor] - Alias for 'I'
  30. * I[xy_factor] - New XY skew factor
  31. * J[xz_factor] - New XZ skew factor
  32. * K[yz_factor] - New YZ skew factor
  33. */
  34. void GcodeSuite::M852() {
  35. uint8_t ijk = 0, badval = 0, setval = 0;
  36. if (parser.seen('I') || parser.seen('S')) {
  37. ++ijk;
  38. const float value = parser.value_linear_units();
  39. if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
  40. if (planner.skew_factor.xy != value) {
  41. planner.skew_factor.xy = value;
  42. ++setval;
  43. }
  44. }
  45. else
  46. ++badval;
  47. }
  48. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  49. if (parser.seen('J')) {
  50. ++ijk;
  51. const float value = parser.value_linear_units();
  52. if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
  53. if (planner.skew_factor.xz != value) {
  54. planner.skew_factor.xz = value;
  55. ++setval;
  56. }
  57. }
  58. else
  59. ++badval;
  60. }
  61. if (parser.seen('K')) {
  62. ++ijk;
  63. const float value = parser.value_linear_units();
  64. if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
  65. if (planner.skew_factor.yz != value) {
  66. planner.skew_factor.yz = value;
  67. ++setval;
  68. }
  69. }
  70. else
  71. ++badval;
  72. }
  73. #endif
  74. if (badval)
  75. SERIAL_ECHOLNPGM(STR_SKEW_MIN " " STRINGIFY(SKEW_FACTOR_MIN) " " STR_SKEW_MAX " " STRINGIFY(SKEW_FACTOR_MAX));
  76. // When skew is changed the current position changes
  77. if (setval) {
  78. set_current_from_steppers_for_axis(ALL_AXES);
  79. sync_plan_position();
  80. report_current_position();
  81. }
  82. if (!ijk) {
  83. SERIAL_ECHO_START();
  84. serialprintPGM(GET_TEXT(MSG_SKEW_FACTOR));
  85. SERIAL_ECHOPAIR_F(" XY: ", planner.skew_factor.xy, 6);
  86. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  87. SERIAL_ECHOPAIR_F(" XZ: ", planner.skew_factor.xz, 6);
  88. SERIAL_ECHOPAIR_F(" YZ: ", planner.skew_factor.yz, 6);
  89. #endif
  90. SERIAL_EOL();
  91. }
  92. }
  93. #endif // SKEW_CORRECTION_GCODE