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.

G30.cpp 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_BED_PROBE
  24. #include "../gcode.h"
  25. #include "../../module/motion.h"
  26. #include "../../module/probe.h"
  27. #include "../../feature/bedlevel/bedlevel.h"
  28. /**
  29. * G30: Do a single Z probe at the current XY
  30. *
  31. * Parameters:
  32. *
  33. * X Probe X position (default current X)
  34. * Y Probe Y position (default current Y)
  35. * E Engage the probe for each probe (default 1)
  36. */
  37. void GcodeSuite::G30() {
  38. const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
  39. parser.linearval('Y', current_position.y + probe.offset_xy.y) };
  40. if (!probe.can_reach(pos)) return;
  41. // Disable leveling so the planner won't mess with us
  42. TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
  43. remember_feedrate_scaling_off();
  44. const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
  45. const float measured_z = probe.probe_at_point(pos, raise_after, 1);
  46. if (!isnan(measured_z))
  47. SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z));
  48. restore_feedrate_and_scaling();
  49. #ifdef Z_AFTER_PROBING
  50. if (raise_after == PROBE_PT_STOW) probe.move_z_after_probing();
  51. #endif
  52. report_current_position();
  53. }
  54. #endif // HAS_BED_PROBE