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.

M906.cpp 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 HAS_TRINAMIC
  24. #include "../../gcode.h"
  25. #include "../../../feature/tmc_util.h"
  26. #include "../../../module/stepper_indirection.h"
  27. /**
  28. * M906: Set motor current in milliamps using axis codes X, Y, Z, E
  29. * Report driver currents when no axis specified
  30. */
  31. void GcodeSuite::M906() {
  32. uint16_t values[XYZE];
  33. LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
  34. #define TMC_SET_GET_CURRENT(P,Q) do { \
  35. if (values[P##_AXIS]) tmc_set_current(stepper##Q, TMC_##Q, values[P##_AXIS]); \
  36. else tmc_get_current(stepper##Q, TMC_##Q); } while(0)
  37. #if X_IS_TRINAMIC
  38. TMC_SET_GET_CURRENT(X,X);
  39. #endif
  40. #if X2_IS_TRINAMIC
  41. TMC_SET_GET_CURRENT(X,X2);
  42. #endif
  43. #if Y_IS_TRINAMIC
  44. TMC_SET_GET_CURRENT(Y,Y);
  45. #endif
  46. #if Y2_IS_TRINAMIC
  47. TMC_SET_GET_CURRENT(Y,Y2);
  48. #endif
  49. #if Z_IS_TRINAMIC
  50. TMC_SET_GET_CURRENT(Z,Z);
  51. #endif
  52. #if Z2_IS_TRINAMIC
  53. TMC_SET_GET_CURRENT(Z,Z2);
  54. #endif
  55. #if E0_IS_TRINAMIC
  56. TMC_SET_GET_CURRENT(E,E0);
  57. #endif
  58. #if E1_IS_TRINAMIC
  59. TMC_SET_GET_CURRENT(E,E1);
  60. #endif
  61. #if E2_IS_TRINAMIC
  62. TMC_SET_GET_CURRENT(E,E2);
  63. #endif
  64. #if E3_IS_TRINAMIC
  65. TMC_SET_GET_CURRENT(E,E3);
  66. #endif
  67. #if E4_IS_TRINAMIC
  68. TMC_SET_GET_CURRENT(E,E4);
  69. #endif
  70. }
  71. #endif // HAS_TRINAMIC