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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.seenval('P')) return;
  35. const int servo_index = parser.value_int();
  36. if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
  37. #if ENABLED(BLTOUCH)
  38. if (servo_index == Z_PROBE_SERVO_NR) {
  39. SERIAL_ERROR_MSG("BLTouch angles can't be changed.");
  40. return;
  41. }
  42. #endif
  43. bool angle_change = false;
  44. if (parser.seen('L')) {
  45. servo_angles[servo_index][0] = parser.value_int();
  46. angle_change = true;
  47. }
  48. if (parser.seen('U')) {
  49. servo_angles[servo_index][1] = parser.value_int();
  50. angle_change = true;
  51. }
  52. if (!angle_change) {
  53. SERIAL_ECHO_START();
  54. SERIAL_ECHOLNPAIR(" Servo ", servo_index,
  55. " L", servo_angles[servo_index][0],
  56. " U", servo_angles[servo_index][1]);
  57. }
  58. }
  59. else {
  60. SERIAL_ERROR_START();
  61. SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range");
  62. }
  63. }
  64. #endif // EDITABLE_SERVO_ANGLES