My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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(BABYSTEPPING)
  24. #include "babystep.h"
  25. #include "../MarlinCore.h"
  26. #include "../module/planner.h"
  27. #include "../module/stepper.h"
  28. #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
  29. #include "../gcode/gcode.h"
  30. #endif
  31. Babystep babystep;
  32. volatile int16_t Babystep::steps[BS_AXIS_IND(Z_AXIS) + 1];
  33. #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
  34. int16_t Babystep::axis_total[BS_TOTAL_IND(Z_AXIS) + 1];
  35. #endif
  36. int16_t Babystep::accum;
  37. void Babystep::step_axis(const AxisEnum axis) {
  38. const int16_t curTodo = steps[BS_AXIS_IND(axis)]; // get rid of volatile for performance
  39. if (curTodo) {
  40. stepper.do_babystep((AxisEnum)axis, curTodo > 0);
  41. if (curTodo > 0) steps[BS_AXIS_IND(axis)]--; else steps[BS_AXIS_IND(axis)]++;
  42. }
  43. }
  44. void Babystep::add_mm(const AxisEnum axis, const float &mm) {
  45. add_steps(axis, mm * planner.settings.axis_steps_per_mm[axis]);
  46. }
  47. void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
  48. if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return;
  49. accum += distance; // Count up babysteps for the UI
  50. #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
  51. axis_total[BS_TOTAL_IND(axis)] += distance;
  52. #endif
  53. #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
  54. #define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: ENABLE_AXIS_X(); break; case Y_AXIS: ENABLE_AXIS_Y(); break; case Z_AXIS: ENABLE_AXIS_Z(); break; default: break; } }while(0)
  55. #else
  56. #define BSA_ENABLE(AXIS) NOOP
  57. #endif
  58. #if IS_CORE
  59. #if ENABLED(BABYSTEP_XY)
  60. switch (axis) {
  61. case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ
  62. BSA_ENABLE(CORE_AXIS_1);
  63. BSA_ENABLE(CORE_AXIS_2);
  64. steps[CORE_AXIS_1] += distance * 2;
  65. steps[CORE_AXIS_2] += distance * 2;
  66. break;
  67. case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ
  68. BSA_ENABLE(CORE_AXIS_1);
  69. BSA_ENABLE(CORE_AXIS_2);
  70. steps[CORE_AXIS_1] += CORESIGN(distance * 2);
  71. steps[CORE_AXIS_2] -= CORESIGN(distance * 2);
  72. break;
  73. case NORMAL_AXIS: // Z on CoreXY, Y on CoreXZ, X on CoreYZ
  74. default:
  75. BSA_ENABLE(NORMAL_AXIS);
  76. steps[NORMAL_AXIS] += distance;
  77. break;
  78. }
  79. #elif CORE_IS_XZ || CORE_IS_YZ
  80. // Only Z stepping needs to be handled here
  81. BSA_ENABLE(CORE_AXIS_1);
  82. BSA_ENABLE(CORE_AXIS_2);
  83. steps[CORE_AXIS_1] += CORESIGN(distance * 2);
  84. steps[CORE_AXIS_2] -= CORESIGN(distance * 2);
  85. #else
  86. BSA_ENABLE(Z_AXIS);
  87. steps[Z_AXIS] += distance;
  88. #endif
  89. #else
  90. #if ENABLED(BABYSTEP_XY)
  91. BSA_ENABLE(axis);
  92. #else
  93. BSA_ENABLE(Z_AXIS);
  94. #endif
  95. steps[BS_AXIS_IND(axis)] += distance;
  96. #endif
  97. #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
  98. gcode.reset_stepper_timeout();
  99. #endif
  100. #if ENABLED(INTEGRATED_BABYSTEPPING)
  101. if (has_steps()) stepper.initiateBabystepping();
  102. #endif
  103. }
  104. #endif // BABYSTEPPING