Make M851 standard with a bed probe

This commit is contained in:
Scott Lahteine 2016-06-14 18:05:20 -07:00
parent cabb71ff38
commit 1000563d80
24 changed files with 26 additions and 260 deletions

View file

@ -719,18 +719,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -319,7 +319,7 @@ float code_value_temp_diff();
extern float z_endstop_adj; extern float z_endstop_adj;
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if HAS_BED_PROBE
extern float zprobe_zoffset; extern float zprobe_zoffset;
#endif #endif

View file

@ -364,9 +364,12 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL
static uint8_t target_extruder; static uint8_t target_extruder;
#if HAS_BED_PROBE
float zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
int xy_travel_speed = XY_TRAVEL_SPEED; int xy_travel_speed = XY_TRAVEL_SPEED;
float zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
bool bed_leveling_in_progress = false; bool bed_leveling_in_progress = false;
#endif #endif
@ -1490,7 +1493,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
current_position[axis] = base_home_pos(axis) + home_offset[axis]; current_position[axis] = base_home_pos(axis) + home_offset[axis];
update_software_endstops(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) { if (axis == Z_AXIS) {
current_position[Z_AXIS] -= zprobe_zoffset; current_position[Z_AXIS] -= zprobe_zoffset;
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
@ -6263,9 +6266,9 @@ inline void gcode_M503() {
#endif // ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED #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_ECHO_START;
SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET); SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET);
@ -6291,7 +6294,7 @@ inline void gcode_M503() {
SERIAL_EOL; SERIAL_EOL;
} }
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET #endif // HAS_BED_PROBE
#if ENABLED(FILAMENTCHANGEENABLE) #if ENABLED(FILAMENTCHANGEENABLE)
@ -7400,7 +7403,7 @@ void process_next_command() {
#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET #ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET: case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET:
gcode_SET_Z_PROBE_OFFSET(); gcode_M851();
break; break;
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET #endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET

View file

@ -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); for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_WRITE_VAR(i, dummy);
#endif // MESH_BED_LEVELING #endif // MESH_BED_LEVELING
#if DISABLED(AUTO_BED_LEVELING_FEATURE) #if !HAS_BED_PROBE
float zprobe_zoffset = 0; float zprobe_zoffset = 0;
#endif #endif
EEPROM_WRITE_VAR(i, zprobe_zoffset); EEPROM_WRITE_VAR(i, zprobe_zoffset);
@ -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); for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy);
#endif // MESH_BED_LEVELING #endif // MESH_BED_LEVELING
#if DISABLED(AUTO_BED_LEVELING_FEATURE) #if !HAS_BED_PROBE
float zprobe_zoffset = 0; float zprobe_zoffset = 0;
#endif #endif
EEPROM_READ_VAR(i, zprobe_zoffset); EEPROM_READ_VAR(i, zprobe_zoffset);
@ -554,7 +554,7 @@ void Config_ResetDefault() {
mbl.reset(); mbl.reset();
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if HAS_BED_PROBE
zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER; zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif #endif
@ -927,20 +927,13 @@ void Config_PrintSettings(bool forReplay) {
/** /**
* Auto Bed Leveling * Auto Bed Leveling
*/ */
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if HAS_BED_PROBE
#if ENABLED(CUSTOM_M_CODES)
if (!forReplay) { if (!forReplay) {
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOLNPGM("Z-Probe Offset (mm):"); SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M" STRINGIFY(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET) " Z", zprobe_zoffset); SERIAL_ECHOPAIR(" M851 Z", zprobe_zoffset);
#else
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOPAIR("Z-Probe Offset (mm):", zprobe_zoffset);
}
#endif
SERIAL_EOL; SERIAL_EOL;
#endif #endif
} }

View file

@ -718,18 +718,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -702,18 +702,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -700,18 +700,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -711,18 +711,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -713,17 +713,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= Additional Features ===========================
//============================================================================= //=============================================================================
// @section more // @section probes
// 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 -5 #define Z_PROBE_OFFSET_RANGE_MIN -5
#define Z_PROBE_OFFSET_RANGE_MAX 0 #define Z_PROBE_OFFSET_RANGE_MAX 0
#endif
#endif
// @section extras // @section extras

View file

@ -736,18 +736,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -719,18 +719,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -714,18 +714,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -727,18 +727,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -740,18 +740,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -711,18 +711,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -719,18 +719,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -808,18 +808,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -802,18 +802,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -805,18 +805,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -805,17 +805,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= Additional Features ===========================
//============================================================================= //=============================================================================
// @section more // @section probes
// 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 -15 #define Z_PROBE_OFFSET_RANGE_MIN -15
#define Z_PROBE_OFFSET_RANGE_MAX -5 #define Z_PROBE_OFFSET_RANGE_MAX 5
#endif
#endif
// @section extras // @section extras

View file

@ -807,18 +807,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -722,18 +722,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -713,18 +713,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//============================= Additional Features =========================== //============================= 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 // @section extras
// //

View file

@ -1684,7 +1684,7 @@ static void lcd_status_screen() {
static void lcd_control_motion_menu() { static void lcd_control_motion_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_CONTROL); MENU_ITEM(back, MSG_CONTROL);
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if HAS_BED_PROBE
MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif #endif
// Manual bed leveling, Bed Z: // Manual bed leveling, Bed Z: