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.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 HAS_MICROSTEPS
  24. #include "../gcode.h"
  25. #include "../../module/stepper.h"
  26. /**
  27. * M350: Set axis microstepping modes. S sets mode for all drivers.
  28. *
  29. * Warning: Steps-per-unit remains unchanged.
  30. */
  31. void GcodeSuite::M350() {
  32. if (parser.seen('S')) LOOP_LE_N(i, 4) stepper.microstep_mode(i, parser.value_byte());
  33. LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.microstep_mode(i, parser.value_byte());
  34. if (parser.seen('B')) stepper.microstep_mode(4, parser.value_byte());
  35. stepper.microstep_readings();
  36. }
  37. /**
  38. * M351: Toggle MS1 MS2 pins directly with axis codes X Y Z E B
  39. * S# determines MS1, MS2 or MS3, X# sets the pin high/low.
  40. */
  41. void GcodeSuite::M351() {
  42. if (parser.seenval('S')) switch (parser.value_byte()) {
  43. case 1:
  44. LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1, -1);
  45. if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1, -1);
  46. break;
  47. case 2:
  48. LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte(), -1);
  49. if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte(), -1);
  50. break;
  51. case 3:
  52. LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, -1, parser.value_byte());
  53. if (parser.seenval('B')) stepper.microstep_ms(4, -1, -1, parser.value_byte());
  54. break;
  55. }
  56. stepper.microstep_readings();
  57. }
  58. #endif // HAS_MICROSTEPS