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.

M281.cpp 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 ENABLED(EDITABLE_SERVO_ANGLES)
  24. #include "../gcode.h"
  25. #include "../../module/servo.h"
  26. /**
  27. * M281 - Edit / Report Servo Angles
  28. *
  29. * P<index> - Servo to update
  30. * L<angle> - Deploy Angle
  31. * U<angle> - Stowed Angle
  32. */
  33. void GcodeSuite::M281() {
  34. if (!parser.seen_any()) return M281_report();
  35. if (!parser.seenval('P')) return;
  36. const int servo_index = parser.value_int();
  37. if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
  38. #if ENABLED(BLTOUCH)
  39. if (servo_index == Z_PROBE_SERVO_NR) {
  40. SERIAL_ERROR_MSG("BLTouch angles can't be changed.");
  41. return;
  42. }
  43. #endif
  44. if (parser.seen('L')) servo_angles[servo_index][0] = parser.value_int();
  45. if (parser.seen('U')) servo_angles[servo_index][1] = parser.value_int();
  46. }
  47. else
  48. SERIAL_ERROR_MSG("Servo ", servo_index, " out of range");
  49. }
  50. void GcodeSuite::M281_report(const bool forReplay/*=true*/) {
  51. report_heading_etc(forReplay, PSTR(STR_SERVO_ANGLES));
  52. LOOP_L_N(i, NUM_SERVOS) {
  53. switch (i) {
  54. default: break;
  55. #if ENABLED(SWITCHING_EXTRUDER)
  56. case SWITCHING_EXTRUDER_SERVO_NR:
  57. #if EXTRUDERS > 3
  58. case SWITCHING_EXTRUDER_E23_SERVO_NR:
  59. #endif
  60. #elif ENABLED(SWITCHING_NOZZLE)
  61. case SWITCHING_NOZZLE_SERVO_NR:
  62. #elif ENABLED(BLTOUCH) || (HAS_Z_SERVO_PROBE && defined(Z_SERVO_ANGLES))
  63. case Z_PROBE_SERVO_NR:
  64. #endif
  65. report_echo_start(forReplay);
  66. SERIAL_ECHOLNPGM(" M281 P", i, " L", servo_angles[i][0], " U", servo_angles[i][1]);
  67. }
  68. }
  69. }
  70. #endif // EDITABLE_SERVO_ANGLES