Skip to content

Commit

Permalink
Added a feature define G28_AUTOSET_Z_HOME_OFFSET
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhubott committed Jan 26, 2016
1 parent 5173a78 commit 865f2bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define DEBUG_LEVELING_FEATURE
#define Z_MIN_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#define SAVE_G29_CORRECTION_MATRIX // if not commented out and the EEPROM is used to save settings, the G29 information will also be saved.
#define G28_AUTOSET_Z_HOME_OFFSET // Add the P code to the G28 command to set the home z offset automatically using the leveling feature

#if ENABLED(AUTO_BED_LEVELING_FEATURE)

Expand Down
12 changes: 8 additions & 4 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2305,8 +2305,10 @@ inline void gcode_G28() {

bool homeX = code_seen(axis_codes[X_AXIS]),
homeY = code_seen(axis_codes[Y_AXIS]),
homeZ = code_seen(axis_codes[Z_AXIS]),
setZhomeOffset = code_seen('P');
#if ENABLED(G28_AUTOSET_Z_HOME_OFFSET)
setZhomeOffset = code_seen('P'),
#endif
homeZ = code_seen(axis_codes[Z_AXIS]);

home_all_axis = (!homeX && !homeY && !homeZ && !setZhomeOffset) || (homeX && homeY && homeZ);

Expand All @@ -2316,11 +2318,13 @@ inline void gcode_G28() {
homeZ = true;
}

#if ENABLED(G28_AUTOSET_Z_HOME_OFFSET)
if(setZhomeOffset)
{
home_offset[Z_AXIS] = 0;
home_all_axis = true; //Home all axis's to get the best Z home offset calculation
}
#endif

if (home_all_axis || homeZ) {

Expand Down Expand Up @@ -2573,7 +2577,7 @@ inline void gcode_G28() {

sync_plan_position();

#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#if ENABLED(G28_AUTOSET_Z_HOME_OFFSET)
if (setZhomeOffset)
{
float measured_z = probe_pt(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING, ProbeStay, 1);
Expand Down Expand Up @@ -2606,7 +2610,7 @@ inline void gcode_G28() {
#endif

//Set the z-level by using 1 point
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#if ENABLED(G28_AUTOSET_Z_HOME_OFFSET)
if (setZhomeOffset)
{
correctZHeight();
Expand Down

0 comments on commit 865f2bd

Please sign in to comment.