MCPcopy Create free account
hub / github.com/MarlinFirmware/Marlin / G35

Method G35

Marlin/src/gcode/bedlevel/G35.cpp:57–157  ·  view source on GitHub ↗

* G35: Read bed corners to help adjust bed screws * * S * * Screw thread: 30 - Clockwise M3 * 31 - Counter-Clockwise M3 * 40 - Clockwise M4 * 41 - Counter-Clockwise M4 * 50 - Clockwise M5 * 51 - Counter-Clockwise M5 */

Source from the content-addressed store, hash-verified

55 * 51 - Counter-Clockwise M5
56 */
57void GcodeSuite::G35() {
58
59 DEBUG_SECTION(log_G35, "G35", DEBUGGING(LEVELING));
60
61 if (DEBUGGING(LEVELING)) log_machine_info();
62
63 float z_measured[G35_PROBE_COUNT] = { 0 };
64
65 const uint8_t screw_thread = parser.byteval('S', TRAMMING_SCREW_THREAD);
66 if (!WITHIN(screw_thread, 30, 51) || screw_thread % 10 > 1) {
67 SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(S)crew thread must be 30, 31, 40, 41, 50, or 51."));
68 return;
69 }
70
71 // Wait for planner moves to finish!
72 planner.synchronize();
73
74 // Disable the leveling matrix before auto-aligning
75 #if HAS_LEVELING
76 #if ENABLED(RESTORE_LEVELING_AFTER_G35)
77 const bool leveling_was_active = planner.leveling_active;
78 #endif
79 set_bed_leveling_enabled(false);
80 #endif
81
82 TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
83
84 probe.use_probing_tool();
85
86 // Disable duplication mode on homing
87 TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));
88
89 // Home only Z axis when X and Y is trusted, otherwise all axes, if needed before this procedure
90 if (!all_axes_trusted()) process_subcommands_now(F("G28Z"));
91
92 bool err_break = false;
93
94 // Probe all positions
95 for (uint8_t i = 0; i < G35_PROBE_COUNT; ++i) {
96 const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE);
97 if (isnan(z_probed_height)) {
98 SERIAL_ECHOLN(
99 F("G35 failed at point "), i + 1,
100 F(" ("), FPSTR(pgm_read_ptr(&tramming_point_name[i])), C(')'),
101 FPSTR(SP_X_STR), tramming_points[i].x,
102 FPSTR(SP_Y_STR), tramming_points[i].y
103 );
104 err_break = true;
105 break;
106 }
107
108 if (DEBUGGING(LEVELING)) {
109 DEBUG_ECHOLN(
110 F("Probing point "), i + 1, F(" ("), FPSTR(pgm_read_ptr(&tramming_point_name[i])), C(')'),
111 FPSTR(SP_X_STR), tramming_points[i].x, FPSTR(SP_Y_STR), tramming_points[i].y,
112 FPSTR(SP_Z_STR), z_probed_height
113 );
114 }

Callers

nothing calls this directly

Calls 15

log_machine_infoFunction · 0.85
set_bed_leveling_enabledFunction · 0.85
all_axes_trustedFunction · 0.85
ABSFunction · 0.85
SERIAL_EOLFunction · 0.85
bytevalMethod · 0.80
use_probing_toolMethod · 0.80
set_duplication_enabledFunction · 0.50
FFunction · 0.50
SERIAL_ECHOLNFunction · 0.50
CFunction · 0.50

Tested by

no test coverage detected