Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make M851 standard with a bed probe #4066

Merged
merged 4 commits into from
Jun 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions Marlin/Conditionals.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,24 +383,6 @@
#define Z_SAFE_HOMING
#endif

/**
* Z Safe Homing dependencies
*/
#if ENABLED(Z_SAFE_HOMING)
#ifndef X_PROBE_OFFSET_FROM_EXTRUDER
#define X_PROBE_OFFSET_FROM_EXTRUDER 0
#endif
#ifndef Y_PROBE_OFFSET_FROM_EXTRUDER
#define Y_PROBE_OFFSET_FROM_EXTRUDER 0
#endif
#ifndef Z_PROBE_OFFSET_FROM_EXTRUDER
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0
#endif
#ifndef XY_TRAVEL_SPEED
#define XY_TRAVEL_SPEED 4000
#endif
#endif

/**
* Host keep alive
*/
Expand Down Expand Up @@ -785,6 +767,30 @@

#define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED)

/**
* Probe dependencies
*/
#if HAS_BED_PROBE
#ifndef X_PROBE_OFFSET_FROM_EXTRUDER
#define X_PROBE_OFFSET_FROM_EXTRUDER 0
#endif
#ifndef Y_PROBE_OFFSET_FROM_EXTRUDER
#define Y_PROBE_OFFSET_FROM_EXTRUDER 0
#endif
#ifndef Z_PROBE_OFFSET_FROM_EXTRUDER
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0
#endif
#ifndef Z_PROBE_OFFSET_RANGE_MIN
#define Z_PROBE_OFFSET_RANGE_MIN -20
#endif
#ifndef Z_PROBE_OFFSET_RANGE_MAX
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
#ifndef XY_TRAVEL_SPEED
#define XY_TRAVEL_SPEED 4000
#endif
#endif

/**
* Delta radius/rod trimmers
*/
Expand Down
14 changes: 1 addition & 13 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
#endif


// @section movement
// @section motion

/**
* MOVEMENT SETTINGS
Expand Down Expand Up @@ -719,18 +719,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features ===========================
//=============================================================================

// @section more

// Custom M code points
#define CUSTOM_M_CODES
#if ENABLED(CUSTOM_M_CODES)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
#endif

// @section extras

//
Expand Down
9 changes: 5 additions & 4 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@
//#define USE_SMALL_INFOFONT
#endif // DOGLCD

// @section more
// @section safety

// The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
// The hardware watchdog should reset the microcontroller disabling all outputs,
// in case the firmware gets stuck and doesn't do temperature regulation.
#define USE_WATCHDOG

#if ENABLED(USE_WATCHDOG)
Expand Down Expand Up @@ -510,9 +511,9 @@ const unsigned int dropsegments = 5; //everything with less than this number of
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
#endif

// @section more
// @section serial

//The ASCII buffer for receiving from the serial:
// The ASCII buffer for serial input
#define MAX_CMD_SIZE 96
#define BUFSIZE 4

Expand Down
2 changes: 1 addition & 1 deletion Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ float code_value_temp_diff();
extern float z_endstop_adj;
#endif

#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#if HAS_BED_PROBE
extern float zprobe_zoffset;
#endif

Expand Down
15 changes: 9 additions & 6 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,12 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL

static uint8_t target_extruder;

#if HAS_BED_PROBE
float zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif

#if ENABLED(AUTO_BED_LEVELING_FEATURE)
int xy_travel_speed = XY_TRAVEL_SPEED;
float zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
bool bed_leveling_in_progress = false;
#endif

Expand Down Expand Up @@ -1490,7 +1493,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
current_position[axis] = base_home_pos(axis) + home_offset[axis];
update_software_endstops(axis);

#if ENABLED(AUTO_BED_LEVELING_FEATURE) && Z_HOME_DIR < 0
#if HAS_BED_PROBE && Z_HOME_DIR < 0
if (axis == Z_AXIS) {
current_position[Z_AXIS] -= zprobe_zoffset;
#if ENABLED(DEBUG_LEVELING_FEATURE)
Expand Down Expand Up @@ -6263,9 +6266,9 @@ inline void gcode_M503() {

#endif // ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED

#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
#if HAS_BED_PROBE

inline void gcode_SET_Z_PROBE_OFFSET() {
inline void gcode_M851() {

SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET);
Expand All @@ -6291,7 +6294,7 @@ inline void gcode_M503() {
SERIAL_EOL;
}

#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
#endif // HAS_BED_PROBE

#if ENABLED(FILAMENTCHANGEENABLE)

Expand Down Expand Up @@ -7400,7 +7403,7 @@ void process_next_command() {

#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET:
gcode_SET_Z_PROBE_OFFSET();
gcode_M851();
break;
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET

Expand Down
25 changes: 9 additions & 16 deletions Marlin/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Config_StoreSettings() {
for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_WRITE_VAR(i, dummy);
#endif // MESH_BED_LEVELING

#if DISABLED(AUTO_BED_LEVELING_FEATURE)
#if !HAS_BED_PROBE
float zprobe_zoffset = 0;
#endif
EEPROM_WRITE_VAR(i, zprobe_zoffset);
Expand Down Expand Up @@ -389,7 +389,7 @@ void Config_RetrieveSettings() {
for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy);
#endif // MESH_BED_LEVELING

#if DISABLED(AUTO_BED_LEVELING_FEATURE)
#if !HAS_BED_PROBE
float zprobe_zoffset = 0;
#endif
EEPROM_READ_VAR(i, zprobe_zoffset);
Expand Down Expand Up @@ -554,7 +554,7 @@ void Config_ResetDefault() {
mbl.reset();
#endif

#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#if HAS_BED_PROBE
zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif

Expand Down Expand Up @@ -927,20 +927,13 @@ void Config_PrintSettings(bool forReplay) {
/**
* Auto Bed Leveling
*/
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#if ENABLED(CUSTOM_M_CODES)
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
}
#if HAS_BED_PROBE
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M" STRINGIFY(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET) " Z", zprobe_zoffset);
#else
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOPAIR("Z-Probe Offset (mm):", zprobe_zoffset);
}
#endif
SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
}
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M851 Z", zprobe_zoffset);
SERIAL_EOL;
#endif
}
Expand Down
14 changes: 1 addition & 13 deletions Marlin/example_configurations/Cartesio/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
#endif


// @section movement
// @section motion

/**
* MOVEMENT SETTINGS
Expand Down Expand Up @@ -718,18 +718,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features ===========================
//=============================================================================

// @section more

// Custom M code points
#define CUSTOM_M_CODES
#if ENABLED(CUSTOM_M_CODES)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
#endif

// @section extras

//
Expand Down
9 changes: 5 additions & 4 deletions Marlin/example_configurations/Cartesio/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@
//#define USE_SMALL_INFOFONT
#endif // DOGLCD

// @section more
// @section safety

// The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
// The hardware watchdog should reset the microcontroller disabling all outputs,
// in case the firmware gets stuck and doesn't do temperature regulation.
#define USE_WATCHDOG

#if ENABLED(USE_WATCHDOG)
Expand Down Expand Up @@ -510,9 +511,9 @@ const unsigned int dropsegments = 5; //everything with less than this number of
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
#endif

// @section more
// @section serial

//The ASCII buffer for receiving from the serial:
// The ASCII buffer for serial input
#define MAX_CMD_SIZE 96
#define BUFSIZE 4

Expand Down
14 changes: 1 addition & 13 deletions Marlin/example_configurations/Felix/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
#endif


// @section movement
// @section motion

/**
* MOVEMENT SETTINGS
Expand Down Expand Up @@ -702,18 +702,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features ===========================
//=============================================================================

// @section more

// Custom M code points
#define CUSTOM_M_CODES
#if ENABLED(CUSTOM_M_CODES)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
#endif

// @section extras

//
Expand Down
9 changes: 5 additions & 4 deletions Marlin/example_configurations/Felix/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@
//#define USE_SMALL_INFOFONT
#endif // DOGLCD

// @section more
// @section safety

// The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
// The hardware watchdog should reset the microcontroller disabling all outputs,
// in case the firmware gets stuck and doesn't do temperature regulation.
#define USE_WATCHDOG

#if ENABLED(USE_WATCHDOG)
Expand Down Expand Up @@ -510,9 +511,9 @@ const unsigned int dropsegments = 5; //everything with less than this number of
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
#endif

// @section more
// @section serial

//The ASCII buffer for receiving from the serial:
// The ASCII buffer for serial input
#define MAX_CMD_SIZE 96
#define BUFSIZE 4

Expand Down
14 changes: 1 addition & 13 deletions Marlin/example_configurations/Felix/DUAL/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
#endif


// @section movement
// @section motion

/**
* MOVEMENT SETTINGS
Expand Down Expand Up @@ -700,18 +700,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features ===========================
//=============================================================================

// @section more

// Custom M code points
#define CUSTOM_M_CODES
#if ENABLED(CUSTOM_M_CODES)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
#endif

// @section extras

//
Expand Down
14 changes: 1 addition & 13 deletions Marlin/example_configurations/Hephestos/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
#endif


// @section movement
// @section motion

/**
* MOVEMENT SETTINGS
Expand Down Expand Up @@ -711,18 +711,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//============================= Additional Features ===========================
//=============================================================================

// @section more

// Custom M code points
#define CUSTOM_M_CODES
#if ENABLED(CUSTOM_M_CODES)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
#endif

// @section extras

//
Expand Down
Loading