Consolidate "bedlevel" code
This commit is contained in:
@ -20,6 +20,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_LEVELING
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#include "../../module/planner.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
#include "../../module/configuration_store.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* M420: Enable/Disable Bed Leveling and/or set the Z fade height.
|
||||
*
|
||||
@ -31,7 +43,7 @@
|
||||
*
|
||||
* L[index] Load UBL mesh from index (0 is default)
|
||||
*/
|
||||
void gcode_M420() {
|
||||
void GcodeSuite::M420() {
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
@ -64,10 +76,10 @@ void gcode_M420() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// L to load a mesh from the EEPROM
|
||||
// L or V display the map info
|
||||
if (parser.seen('L') || parser.seen('V')) {
|
||||
ubl.display_map(0); // Currently only supports one map type
|
||||
SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
|
||||
SERIAL_ECHOLNPAIR("ubl.mesh_is_valid = ", ubl.mesh_is_valid());
|
||||
SERIAL_ECHOLNPAIR("ubl.state.storage_slot = ", ubl.state.storage_slot);
|
||||
}
|
||||
|
||||
@ -119,3 +131,5 @@ void gcode_M420() {
|
||||
SERIAL_ECHOLNPGM(MSG_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAS_LEVELING
|
@ -20,6 +20,29 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* G29.cpp - Auto Bed Leveling
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if OLDSCHOOL_ABL
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/bedlevel/bedlevel.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../module/stepper.h"
|
||||
#include "../../../module/probe.h"
|
||||
|
||||
#if ENABLED(LCD_BED_LEVELING) && ENABLED(PROBE_MANUALLY)
|
||||
#include "../../../lcd/ultralcd.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
#include "../../../libs/least_squares_fit.h"
|
||||
#endif
|
||||
|
||||
#if ABL_GRID
|
||||
#if ENABLED(PROBE_Y_FIRST)
|
||||
#define PR_OUTER_VAR xCount
|
||||
@ -106,7 +129,7 @@
|
||||
* There's no extra effect if you have a fixed Z probe.
|
||||
*
|
||||
*/
|
||||
void gcode_G29() {
|
||||
void GcodeSuite::G29() {
|
||||
|
||||
// G29 Q is also available if debugging
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
@ -176,12 +199,10 @@ void gcode_G29() {
|
||||
abl_grid_points_y = GRID_MAX_POINTS_Y;
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(PROBE_MANUALLY)
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
ABL_VAR int abl2;
|
||||
#else // Bilinear
|
||||
int constexpr abl2 = GRID_MAX_POINTS;
|
||||
#endif
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
ABL_VAR int abl2;
|
||||
#elif ENABLED(PROBE_MANUALLY) // Bilinear
|
||||
int constexpr abl2 = GRID_MAX_POINTS;
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
@ -199,7 +220,9 @@ void gcode_G29() {
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
|
||||
int constexpr abl2 = 3;
|
||||
#if ENABLED(PROBE_MANUALLY)
|
||||
int constexpr abl2 = 3; // used to show total points
|
||||
#endif
|
||||
|
||||
// Probe at 3 arbitrary points
|
||||
ABL_VAR vector_3 points[3] = {
|
||||
@ -944,3 +967,5 @@ void gcode_G29() {
|
||||
if (planner.abl_enabled)
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
}
|
||||
|
||||
#endif // OLDSCHOOL_ABL
|
@ -20,6 +20,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M421.cpp - Auto Bed Leveling
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/bedlevel/abl/abl.h"
|
||||
|
||||
/**
|
||||
* M421: Set a single Mesh Bed Leveling Z coordinate
|
||||
*
|
||||
@ -27,7 +38,7 @@
|
||||
* M421 I<xindex> J<yindex> Z<linear>
|
||||
* M421 I<xindex> J<yindex> Q<offset>
|
||||
*/
|
||||
void gcode_M421() {
|
||||
void GcodeSuite::M421() {
|
||||
int8_t ix = parser.intval('I', -1), iy = parser.intval('J', -1);
|
||||
const bool hasI = ix >= 0,
|
||||
hasJ = iy >= 0,
|
||||
@ -49,3 +60,5 @@ void gcode_M421() {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // AUTO_BED_LEVELING_BILINEAR
|
@ -20,26 +20,30 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../queue.h"
|
||||
/**
|
||||
* G29.cpp - Mesh Bed Leveling
|
||||
*/
|
||||
|
||||
#include "../../libs/buzzer.h"
|
||||
#include "../../lcd/ultralcd.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
|
||||
#include "../../../feature/bedlevel/bedlevel.h"
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../queue.h"
|
||||
|
||||
#include "../../../libs/buzzer.h"
|
||||
#include "../../../lcd/ultralcd.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../module/stepper.h"
|
||||
|
||||
// Save 130 bytes with non-duplication of PSTR
|
||||
void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
|
||||
|
||||
void mbl_mesh_report() {
|
||||
SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
|
||||
SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
|
||||
SERIAL_PROTOCOLLNPGM("\nMeasured points:");
|
||||
print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
|
||||
[](const uint8_t ix, const uint8_t iy) { return mbl.z_values[ix][iy]; }
|
||||
);
|
||||
}
|
||||
|
||||
void mesh_probing_done() {
|
||||
mbl.set_has_mesh(true);
|
||||
home_all_axes();
|
||||
gcode.home_all_axes();
|
||||
set_bed_leveling_enabled(true);
|
||||
#if ENABLED(MESH_G28_REST_ORIGIN)
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS);
|
||||
@ -70,7 +74,7 @@ void mesh_probing_done() {
|
||||
* v Y-axis 1-n
|
||||
*
|
||||
*/
|
||||
void gcode_G29() {
|
||||
void GcodeSuite::G29() {
|
||||
|
||||
static int mbl_probe_index = -1;
|
||||
#if HAS_SOFTWARE_ENDSTOPS
|
||||
@ -200,3 +204,5 @@ void gcode_G29() {
|
||||
|
||||
report_current_position();
|
||||
}
|
||||
|
||||
#endif // MESH_BED_LEVELING
|
@ -20,6 +20,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* M421.cpp - Mesh Bed Leveling
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../feature/bedlevel/mbl/mesh_bed_leveling.h"
|
||||
|
||||
/**
|
||||
* M421: Set a single Mesh Bed Leveling Z coordinate
|
||||
*
|
||||
@ -29,7 +41,7 @@
|
||||
* M421 I<xindex> J<yindex> Z<linear>
|
||||
* M421 I<xindex> J<yindex> Q<offset>
|
||||
*/
|
||||
void gcode_M421() {
|
||||
void GcodeSuite::M421() {
|
||||
const bool hasX = parser.seen('X'), hasI = parser.seen('I');
|
||||
const int8_t ix = hasI ? parser.value_int() : hasX ? mbl.probe_index_x(RAW_X_POSITION(parser.value_linear_units())) : -1;
|
||||
const bool hasY = parser.seen('Y'), hasJ = parser.seen('J');
|
||||
@ -47,3 +59,5 @@ void gcode_M421() {
|
||||
else
|
||||
mbl.set_z(ix, iy, parser.value_linear_units() + (hasQ ? mbl.z_values[ix][iy] : 0));
|
||||
}
|
||||
|
||||
#endif // MESH_BED_LEVELING
|
@ -20,8 +20,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void gcode_G29() {
|
||||
/**
|
||||
* G26.cpp - Unified Bed Leveling
|
||||
*/
|
||||
|
||||
ubl.G29();
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
}
|
||||
#if ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/bedlevel/ubl/ubl.h"
|
||||
|
||||
void GcodeSuite::G26() { ubl.G26(); }
|
||||
|
||||
#endif // UBL_G26_MESH_VALIDATION
|
@ -20,8 +20,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void gcode_G26() {
|
||||
/**
|
||||
* G29.cpp - Unified Bed Leveling
|
||||
*/
|
||||
|
||||
ubl.G26();
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
}
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/bedlevel/ubl/ubl.h"
|
||||
|
||||
void GcodeSuite::G29() { ubl.G29(); }
|
||||
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
@ -20,6 +20,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* unified.cpp - Unified Bed Leveling
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/bedlevel/ubl/ubl.h"
|
||||
|
||||
/**
|
||||
* M421: Set a single Mesh Bed Leveling Z coordinate
|
||||
*
|
||||
@ -29,7 +40,7 @@
|
||||
* M421 C Z<linear>
|
||||
* M421 C Q<offset>
|
||||
*/
|
||||
void gcode_M421() {
|
||||
void GcodeSuite::M421() {
|
||||
int8_t ix = parser.intval('I', -1), iy = parser.intval('J', -1);
|
||||
const bool hasI = ix >= 0,
|
||||
hasJ = iy >= 0,
|
||||
@ -54,3 +65,5 @@ void gcode_M421() {
|
||||
else
|
||||
ubl.z_values[ix][iy] = parser.value_linear_units() + (hasQ ? ubl.z_values[ix][iy] : 0);
|
||||
}
|
||||
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
@ -20,8 +20,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void gcode_M49() {
|
||||
/**
|
||||
* M49.cpp - Unified Bed Leveling
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/bedlevel/bedlevel.h"
|
||||
|
||||
void GcodeSuite::M49() {
|
||||
ubl.g26_debug_flag ^= true;
|
||||
SERIAL_PROTOCOLPGM("UBL Debug Flag turned ");
|
||||
serialprintPGM(ubl.g26_debug_flag ? PSTR("on.") : PSTR("off."));
|
||||
}
|
||||
|
||||
#endif // UBL_G26_MESH_VALIDATION
|
@ -20,12 +20,23 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "../gcode.h"
|
||||
|
||||
#include "../../module/stepper.h"
|
||||
#include "../../module/endstops.h"
|
||||
|
||||
#if HOTENDS > 1
|
||||
#include "../control/tool_change.h"
|
||||
#include "../../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
#if HAS_LEVELING
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#include "../../lcd/ultralcd.h"
|
||||
|
||||
#if ENABLED(QUICK_HOME)
|
||||
|
||||
static void quick_home_xy() {
|
||||
@ -126,11 +137,11 @@
|
||||
* Z Home to the Z endstop
|
||||
*
|
||||
*/
|
||||
void gcode_G28(const bool always_home_all) {
|
||||
void GcodeSuite::G28(const bool always_home_all) {
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
SERIAL_ECHOLNPGM(">>> gcode_G28");
|
||||
SERIAL_ECHOLNPGM(">>> G28");
|
||||
log_machine_info();
|
||||
}
|
||||
#endif
|
||||
@ -288,7 +299,7 @@ void gcode_G28(const bool always_home_all) {
|
||||
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
|
||||
#endif // !DELTA (gcode_G28)
|
||||
#endif // !DELTA (G28)
|
||||
|
||||
endstops.not_homing();
|
||||
|
||||
@ -319,6 +330,6 @@ void gcode_G28(const bool always_home_all) {
|
||||
report_current_position();
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28");
|
||||
#endif
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
|
||||
|
||||
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
|
||||
extern bool lcd_wait_for_move;
|
||||
#endif
|
||||
|
||||
inline void _manual_goto_xy(const float &x, const float &y) {
|
||||
const float old_feedrate_mm_s = feedrate_mm_s;
|
||||
#if MANUAL_PROBE_HEIGHT > 0
|
||||
const float prev_z = current_position[Z_AXIS];
|
||||
feedrate_mm_s = homing_feedrate(Z_AXIS);
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(MANUAL_PROBE_HEIGHT);
|
||||
line_to_current_position();
|
||||
#endif
|
||||
|
||||
feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
|
||||
current_position[X_AXIS] = LOGICAL_X_POSITION(x);
|
||||
current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
|
||||
line_to_current_position();
|
||||
|
||||
#if MANUAL_PROBE_HEIGHT > 0
|
||||
feedrate_mm_s = homing_feedrate(Z_AXIS);
|
||||
current_position[Z_AXIS] = prev_z; // move back to the previous Z.
|
||||
line_to_current_position();
|
||||
#endif
|
||||
|
||||
feedrate_mm_s = old_feedrate_mm_s;
|
||||
stepper.synchronize();
|
||||
|
||||
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
|
||||
lcd_wait_for_move = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
#include "G29-mbl.h"
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "G29-ubl.h"
|
||||
#elif HAS_ABL
|
||||
#include "G29-abl.h"
|
||||
#endif
|
@ -20,10 +20,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HOTENDS > 1
|
||||
#include "../control/tool_change.h"
|
||||
#if ENABLED(DELTA_AUTO_CALIBRATION)
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../module/delta.h"
|
||||
#include "../../module/probe.h"
|
||||
#include "../../module/motion.h"
|
||||
#include "../../module/stepper.h"
|
||||
#include "../../module/endstops.h"
|
||||
#include "../../module/tool_change.h"
|
||||
#include "../../lcd/ultralcd.h"
|
||||
|
||||
#if HAS_LEVELING
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -54,7 +65,7 @@
|
||||
* E Engage the probe for each point
|
||||
*/
|
||||
|
||||
void print_signed_float(const char * const prefix, const float &f) {
|
||||
static void print_signed_float(const char * const prefix, const float &f) {
|
||||
SERIAL_PROTOCOLPGM(" ");
|
||||
serialprintPGM(prefix);
|
||||
SERIAL_PROTOCOLCHAR(':');
|
||||
@ -62,12 +73,12 @@ void print_signed_float(const char * const prefix, const float &f) {
|
||||
SERIAL_PROTOCOL_F(f, 2);
|
||||
}
|
||||
|
||||
inline void print_G33_settings(const bool end_stops, const bool tower_angles){ // TODO echo these to LCD ???
|
||||
static void print_G33_settings(const bool end_stops, const bool tower_angles){ // TODO echo these to LCD ???
|
||||
SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
|
||||
if (end_stops) {
|
||||
print_signed_float(PSTR(" Ex"), endstop_adj[A_AXIS]);
|
||||
print_signed_float(PSTR("Ey"), endstop_adj[B_AXIS]);
|
||||
print_signed_float(PSTR("Ez"), endstop_adj[C_AXIS]);
|
||||
print_signed_float(PSTR(" Ex"), delta_endstop_adj[A_AXIS]);
|
||||
print_signed_float(PSTR("Ey"), delta_endstop_adj[B_AXIS]);
|
||||
print_signed_float(PSTR("Ez"), delta_endstop_adj[C_AXIS]);
|
||||
SERIAL_PROTOCOLPAIR(" Radius:", delta_radius);
|
||||
}
|
||||
SERIAL_EOL();
|
||||
@ -79,7 +90,7 @@ inline void print_G33_settings(const bool end_stops, const bool tower_angles){ /
|
||||
}
|
||||
}
|
||||
|
||||
void G33_cleanup(
|
||||
static void G33_cleanup(
|
||||
#if HOTENDS > 1
|
||||
const uint8_t old_tool_index
|
||||
#endif
|
||||
@ -94,7 +105,7 @@ void G33_cleanup(
|
||||
#endif
|
||||
}
|
||||
|
||||
void gcode_G33() {
|
||||
void GcodeSuite::G33() {
|
||||
|
||||
const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
|
||||
if (!WITHIN(probe_points, 1, 7)) {
|
||||
@ -110,7 +121,7 @@ void gcode_G33() {
|
||||
|
||||
const float calibration_precision = parser.floatval('C');
|
||||
if (calibration_precision < 0) {
|
||||
SERIAL_PROTOCOLLNPGM("?(C)alibration precision is implausible (>0).");
|
||||
SERIAL_PROTOCOLLNPGM("?(C)alibration precision is implausible (>=0).");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -121,7 +132,6 @@ void gcode_G33() {
|
||||
}
|
||||
|
||||
const bool towers_set = parser.boolval('T', true),
|
||||
stow_after_each = parser.boolval('E'),
|
||||
_1p_calibration = probe_points == 1,
|
||||
_4p_calibration = probe_points == 2,
|
||||
_4p_towers_points = _4p_calibration && towers_set,
|
||||
@ -133,18 +143,24 @@ void gcode_G33() {
|
||||
_7p_quadruple_circle = probe_points == 7,
|
||||
_7p_multi_circle = _7p_double_circle || _7p_triple_circle || _7p_quadruple_circle,
|
||||
_7p_intermed_points = _7p_calibration && !_7p_half_circle;
|
||||
|
||||
#if DISABLED(PROBE_MANUALLY)
|
||||
const bool stow_after_each = parser.boolval('E');
|
||||
const float dx = (X_PROBE_OFFSET_FROM_EXTRUDER),
|
||||
dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
|
||||
#endif
|
||||
|
||||
const static char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
|
||||
const float dx = (X_PROBE_OFFSET_FROM_EXTRUDER),
|
||||
dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
|
||||
|
||||
int8_t iterations = 0;
|
||||
float test_precision,
|
||||
zero_std_dev = (verbose_level ? 999.0 : 0.0), // 0.0 in dry-run mode : forced end
|
||||
zero_std_dev_old = zero_std_dev,
|
||||
zero_std_dev_min = zero_std_dev,
|
||||
e_old[XYZ] = {
|
||||
endstop_adj[A_AXIS],
|
||||
endstop_adj[B_AXIS],
|
||||
endstop_adj[C_AXIS]
|
||||
delta_endstop_adj[A_AXIS],
|
||||
delta_endstop_adj[B_AXIS],
|
||||
delta_endstop_adj[C_AXIS]
|
||||
},
|
||||
dr_old = delta_radius,
|
||||
zh_old = home_offset[Z_AXIS],
|
||||
@ -167,6 +183,7 @@ void gcode_G33() {
|
||||
SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");
|
||||
|
||||
stepper.synchronize();
|
||||
|
||||
#if HAS_LEVELING
|
||||
reset_bed_level(); // After calibration bed-level data is no longer valid
|
||||
#endif
|
||||
@ -274,7 +291,7 @@ void gcode_G33() {
|
||||
|
||||
if ((zero_std_dev < test_precision && zero_std_dev > calibration_precision) || iterations <= force_iterations) {
|
||||
if (zero_std_dev < zero_std_dev_min) {
|
||||
COPY(e_old, endstop_adj);
|
||||
COPY(e_old, delta_endstop_adj);
|
||||
dr_old = delta_radius;
|
||||
zh_old = home_offset[Z_AXIS];
|
||||
alpha_old = delta_tower_angle_trim[A_AXIS];
|
||||
@ -337,20 +354,20 @@ void gcode_G33() {
|
||||
break;
|
||||
}
|
||||
|
||||
LOOP_XYZ(axis) endstop_adj[axis] += e_delta[axis];
|
||||
LOOP_XYZ(axis) delta_endstop_adj[axis] += e_delta[axis];
|
||||
delta_radius += r_delta;
|
||||
delta_tower_angle_trim[A_AXIS] += t_alpha;
|
||||
delta_tower_angle_trim[B_AXIS] += t_beta;
|
||||
|
||||
// adjust delta_height and endstops by the max amount
|
||||
const float z_temp = MAX3(endstop_adj[A_AXIS], endstop_adj[B_AXIS], endstop_adj[C_AXIS]);
|
||||
const float z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
|
||||
home_offset[Z_AXIS] -= z_temp;
|
||||
LOOP_XYZ(i) endstop_adj[i] -= z_temp;
|
||||
LOOP_XYZ(i) delta_endstop_adj[i] -= z_temp;
|
||||
|
||||
recalc_delta_settings(delta_radius, delta_diagonal_rod);
|
||||
}
|
||||
else if (zero_std_dev >= test_precision) { // step one back
|
||||
COPY(endstop_adj, e_old);
|
||||
COPY(delta_endstop_adj, e_old);
|
||||
delta_radius = dr_old;
|
||||
home_offset[Z_AXIS] = zh_old;
|
||||
delta_tower_angle_trim[A_AXIS] = alpha_old;
|
||||
@ -449,3 +466,5 @@ void gcode_G33() {
|
||||
|
||||
G33_CLEANUP();
|
||||
}
|
||||
|
||||
#endif // DELTA_AUTO_CALIBRATION
|
@ -33,11 +33,11 @@
|
||||
#endif
|
||||
LOOP_XYZ(i) {
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
endstop_adj[i] = parser.value_linear_units();
|
||||
delta_endstop_adj[i] = parser.value_linear_units();
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
SERIAL_ECHOPAIR("endstop_adj[", axis_codes[i]);
|
||||
SERIAL_ECHOLNPAIR("] = ", endstop_adj[i]);
|
||||
SERIAL_ECHOPAIR("delta_endstop_adj[", axis_codes[i]);
|
||||
SERIAL_ECHOLNPAIR("] = ", delta_endstop_adj[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -48,9 +48,9 @@
|
||||
}
|
||||
#endif
|
||||
// normalize endstops so all are <=0; set the residue to delta height
|
||||
const float z_temp = MAX3(endstop_adj[A_AXIS], endstop_adj[B_AXIS], endstop_adj[C_AXIS]);
|
||||
const float z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
|
||||
home_offset[Z_AXIS] -= z_temp;
|
||||
LOOP_XYZ(i) endstop_adj[i] -= z_temp;
|
||||
LOOP_XYZ(i) delta_endstop_adj[i] -= z_temp;
|
||||
}
|
||||
|
||||
#elif ENABLED(Z_DUAL_ENDSTOPS) // !DELTA && ENABLED(Z_DUAL_ENDSTOPS)
|
||||
|
@ -1,81 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALIBRATE_COMMON_H
|
||||
#define CALIBRATE_COMMON_H
|
||||
|
||||
#if ENABLED(DELTA)
|
||||
|
||||
/**
|
||||
* A delta can only safely home all axes at the same time
|
||||
* This is like quick_home_xy() but for 3 towers.
|
||||
*/
|
||||
inline bool home_delta() {
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
|
||||
#endif
|
||||
// Init the current position of all carriages to 0,0,0
|
||||
ZERO(current_position);
|
||||
sync_plan_position();
|
||||
|
||||
// Move all carriages together linearly until an endstop is hit.
|
||||
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
|
||||
feedrate_mm_s = homing_feedrate(X_AXIS);
|
||||
line_to_current_position();
|
||||
stepper.synchronize();
|
||||
|
||||
// If an endstop was not hit, then damage can occur if homing is continued.
|
||||
// This can occur if the delta height (DELTA_HEIGHT + home_offset[Z_AXIS]) is
|
||||
// not set correctly.
|
||||
if (!(Endstops::endstop_hit_bits & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX)))) {
|
||||
LCD_MESSAGEPGM(MSG_ERR_HOMING_FAILED);
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ERRORLNPGM(MSG_ERR_HOMING_FAILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
endstops.hit_on_purpose(); // clear endstop hit flags
|
||||
|
||||
// At least one carriage has reached the top.
|
||||
// Now re-home each carriage separately.
|
||||
HOMEAXIS(A);
|
||||
HOMEAXIS(B);
|
||||
HOMEAXIS(C);
|
||||
|
||||
// Set all carriages to their home positions
|
||||
// Do this here all at once for Delta, because
|
||||
// XYZ isn't ABC. Applying this per-tower would
|
||||
// give the impression that they are the same.
|
||||
LOOP_XYZ(i) set_axis_is_at_home((AxisEnum)i);
|
||||
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // DELTA
|
||||
|
||||
#endif // CALIBRATE_COMMON_H
|
@ -47,7 +47,7 @@ void gcode_M18_M84() {
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD) // Only needed with an LCD
|
||||
ubl_lcd_map_control = defer_return_to_status = false;
|
||||
ubl.lcd_map_control = defer_return_to_status = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -115,14 +115,10 @@ extern void gcode_G18();
|
||||
extern void gcode_G19();
|
||||
extern void gcode_G20();
|
||||
extern void gcode_G21();
|
||||
extern void gcode_G26();
|
||||
extern void gcode_G27();
|
||||
extern void gcode_G28(const bool always_home_all);
|
||||
extern void gcode_G29();
|
||||
extern void gcode_G30();
|
||||
extern void gcode_G31();
|
||||
extern void gcode_G32();
|
||||
extern void gcode_G33();
|
||||
extern void gcode_G38(bool is_38_2);
|
||||
extern void gcode_G42();
|
||||
extern void gcode_G92();
|
||||
@ -149,7 +145,6 @@ extern void gcode_M34();
|
||||
extern void gcode_M42();
|
||||
extern void gcode_M43();
|
||||
extern void gcode_M48();
|
||||
extern void gcode_M49();
|
||||
extern void gcode_M75();
|
||||
extern void gcode_M76();
|
||||
extern void gcode_M77();
|
||||
@ -225,8 +220,6 @@ extern void gcode_M405();
|
||||
extern void gcode_M406();
|
||||
extern void gcode_M407();
|
||||
extern void gcode_M410();
|
||||
extern void gcode_M420();
|
||||
extern void gcode_M421();
|
||||
extern void gcode_M428();
|
||||
extern void gcode_M500();
|
||||
extern void gcode_M501();
|
||||
@ -238,7 +231,6 @@ extern void gcode_M605();
|
||||
extern void gcode_M665();
|
||||
extern void gcode_M666();
|
||||
extern void gcode_M702();
|
||||
extern void gcode_M851();
|
||||
extern void gcode_M900();
|
||||
extern void gcode_M906();
|
||||
extern void gcode_M911();
|
||||
@ -348,9 +340,9 @@ void GcodeSuite::process_next_command() {
|
||||
break;
|
||||
#endif // INCH_MODE_SUPPORT
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
#if ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
case 26: // G26: Mesh Validation Pattern generation
|
||||
gcode_G26();
|
||||
G26();
|
||||
break;
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
||||
@ -361,13 +353,13 @@ void GcodeSuite::process_next_command() {
|
||||
#endif // NOZZLE_PARK_FEATURE
|
||||
|
||||
case 28: // G28: Home all axes, one at a time
|
||||
gcode_G28(false);
|
||||
G28(false);
|
||||
break;
|
||||
|
||||
#if HAS_LEVELING
|
||||
case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
|
||||
// or provides access to the UBL System if enabled.
|
||||
gcode_G29();
|
||||
G29();
|
||||
break;
|
||||
#endif // HAS_LEVELING
|
||||
|
||||
@ -391,17 +383,11 @@ void GcodeSuite::process_next_command() {
|
||||
|
||||
#endif // HAS_BED_PROBE
|
||||
|
||||
#if PROBE_SELECTED
|
||||
|
||||
#if ENABLED(DELTA_AUTO_CALIBRATION)
|
||||
|
||||
case 33: // G33: Delta Auto-Calibration
|
||||
gcode_G33();
|
||||
break;
|
||||
|
||||
#endif // DELTA_AUTO_CALIBRATION
|
||||
|
||||
#endif // PROBE_SELECTED
|
||||
#if ENABLED(DELTA_AUTO_CALIBRATION)
|
||||
case 33: // G33: Delta Auto-Calibration
|
||||
G33();
|
||||
break;
|
||||
#endif // DELTA_AUTO_CALIBRATION
|
||||
|
||||
#if ENABLED(G38_PROBE_TARGET)
|
||||
case 38: // G38.2 & G38.3
|
||||
@ -516,11 +502,9 @@ void GcodeSuite::process_next_command() {
|
||||
break;
|
||||
#endif // Z_MIN_PROBE_REPEATABILITY_TEST
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
case 49: // M49: Turn on or off G26 debug flag for verbose output
|
||||
gcode_M49();
|
||||
break;
|
||||
#endif // AUTO_BED_LEVELING_UBL && UBL_G26_MESH_VALIDATION
|
||||
#if ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
case 49: M49(); break; // M49: Turn on or off G26 debug flag for verbose output
|
||||
#endif
|
||||
|
||||
case 75: // M75: Start print timer
|
||||
gcode_M75(); break;
|
||||
@ -901,13 +885,13 @@ void GcodeSuite::process_next_command() {
|
||||
|
||||
#if HAS_LEVELING
|
||||
case 420: // M420: Enable/Disable Bed Leveling
|
||||
gcode_M420();
|
||||
M420();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
#if HAS_MESH
|
||||
case 421: // M421: Set a Mesh Bed Leveling Z coordinate
|
||||
gcode_M421();
|
||||
M421();
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -941,7 +925,7 @@ void GcodeSuite::process_next_command() {
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
case 851: // M851: Set Z Probe Z Offset
|
||||
gcode_M851();
|
||||
M851();
|
||||
break;
|
||||
#endif // HAS_BED_PROBE
|
||||
|
||||
|
@ -20,43 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void refresh_zprobe_zoffset(const bool no_babystep/*=false*/) {
|
||||
static float last_zoffset = NAN;
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
if (!isnan(last_zoffset)) {
|
||||
#if HAS_BED_PROBE
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(BABYSTEP_ZPROBE_OFFSET) || ENABLED(DELTA)
|
||||
const float diff = zprobe_zoffset - last_zoffset;
|
||||
#endif
|
||||
#include "../gcode.h"
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#include "../../module/probe.h"
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
// Correct bilinear grid for new probe offset
|
||||
if (diff) {
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
z_values[x][y] -= diff;
|
||||
}
|
||||
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
||||
bed_level_virt_interpolate();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
if (!no_babystep && leveling_is_active())
|
||||
thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
|
||||
#else
|
||||
UNUSED(no_babystep);
|
||||
#endif
|
||||
|
||||
#if ENABLED(DELTA) // correct the delta_height
|
||||
home_offset[Z_AXIS] -= diff;
|
||||
#endif
|
||||
}
|
||||
|
||||
last_zoffset = zprobe_zoffset;
|
||||
}
|
||||
|
||||
void gcode_M851() {
|
||||
void GcodeSuite::M851() {
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET " ");
|
||||
if (parser.seen('Z')) {
|
||||
@ -74,3 +46,5 @@ void gcode_M851() {
|
||||
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
#endif // HAS_BED_PROBE
|
Reference in New Issue
Block a user