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.

M350_M351.cpp 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #if HAS_MICROSTEPS
  24. #include "../gcode.h"
  25. #include "../../module/stepper.h"
  26. #if NUM_AXES == XYZ && EXTRUDERS >= 1
  27. #define HAS_M350_B_PARAM 1 // "5th axis" (after E0) for an original XYZEB setup.
  28. #if AXIS_COLLISION('B')
  29. #error "M350 parameter 'B' collision with axis name."
  30. #endif
  31. #endif
  32. /**
  33. * M350: Set axis microstepping modes. S sets mode for all drivers.
  34. *
  35. * Warning: Steps-per-unit remains unchanged.
  36. */
  37. void GcodeSuite::M350() {
  38. if (parser.seen('S')) LOOP_DISTINCT_AXES(i) stepper.microstep_mode(i, parser.value_byte());
  39. LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_mode(i, parser.value_byte());
  40. TERN_(HAS_M350_B_PARAM, if (parser.seenval('B')) stepper.microstep_mode(E_AXIS + 1, parser.value_byte()));
  41. stepper.microstep_readings();
  42. }
  43. /**
  44. * M351: Toggle MS1 MS2 pins directly with axis codes X Y Z . . . E [B]
  45. * S# determines MS1, MS2 or MS3, X# sets the pin high/low.
  46. *
  47. * Parameter 'B' sets "5th axis" (after E0) only for an original XYZEB setup.
  48. */
  49. void GcodeSuite::M351() {
  50. const int8_t bval = TERN(HAS_M350_B_PARAM, parser.byteval('B', -1), -1); UNUSED(bval);
  51. if (parser.seenval('S')) switch (parser.value_byte()) {
  52. case 1:
  53. LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, parser.value_byte(), -1, -1);
  54. TERN_(HAS_M350_B_PARAM, if (bval >= 0) stepper.microstep_ms(E_AXIS + 1, bval != 0, -1, -1));
  55. break;
  56. case 2:
  57. LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, parser.value_byte(), -1);
  58. TERN_(HAS_M350_B_PARAM, if (bval >= 0) stepper.microstep_ms(E_AXIS + 1, -1, bval != 0, -1));
  59. break;
  60. case 3:
  61. LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, -1, parser.value_byte());
  62. TERN_(HAS_M350_B_PARAM, if (bval >= 0) stepper.microstep_ms(E_AXIS + 1, -1, -1, bval != 0));
  63. break;
  64. }
  65. stepper.microstep_readings();
  66. }
  67. #endif // HAS_MICROSTEPS