Merge upstream changes from Marlin 2.1.1

This commit is contained in:
Stefan Kalscheuer
2022-09-03 09:23:32 +02:00
parent 626283aadb
commit 986e416c7f
1610 changed files with 73839 additions and 40857 deletions

View File

@@ -29,6 +29,18 @@
#include "../../module/probe.h"
#include "../../feature/bedlevel/bedlevel.h"
#if HAS_PTC
#include "../../feature/probe_temp_comp.h"
#endif
#if HAS_MULTI_HOTEND
#include "../../module/tool_change.h"
#endif
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
#include "../../lcd/marlinui.h"
#endif
/**
* G30: Do a single Z probe at the current XY
*
@@ -37,30 +49,62 @@
* X Probe X position (default current X)
* Y Probe Y position (default current Y)
* E Engage the probe for each probe (default 1)
* C Enable probe temperature compensation (0 or 1, default 1)
*/
void GcodeSuite::G30() {
#if HAS_MULTI_HOTEND
const uint8_t old_tool_index = active_extruder;
tool_change(0);
#endif
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
parser.linearval('Y', current_position.y + probe.offset_xy.y) };
if (!probe.can_reach(pos)) return;
if (!probe.can_reach(pos)) {
#if ENABLED(DWIN_LCD_PROUI)
SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
LCD_MESSAGE(MSG_ZPROBE_OUT);
#endif
}
else {
// Disable leveling so the planner won't mess with us
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
// Disable leveling so the planner won't mess with us
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
remember_feedrate_scaling_off();
remember_feedrate_scaling_off();
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
process_subcommands_now(F("G28O"));
#endif
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
if (!isnan(measured_z))
SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
restore_feedrate_and_scaling();
TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool()));
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
TERN_(HAS_PTC, ptc.set_enabled(true));
if (!isnan(measured_z)) {
SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
char msg[31], str_1[6], str_2[6], str_3[6];
sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"),
dtostrf(pos.x, 1, 1, str_1),
dtostrf(pos.y, 1, 1, str_2),
dtostrf(measured_z, 1, 2, str_3)
);
ui.set_status(msg);
#endif
}
if (raise_after == PROBE_PT_STOW)
probe.move_z_after_probing();
restore_feedrate_and_scaling();
report_current_position();
if (raise_after == PROBE_PT_STOW)
probe.move_z_after_probing();
report_current_position();
}
// Restore the active tool
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
}
#endif // HAS_BED_PROBE

View File

@@ -28,7 +28,7 @@
#include "../../module/endstops.h"
#include "../../module/motion.h"
#include "../../module/stepper.h"
#include "../../module/planner.h"
#include "../../module/probe.h"
inline void G38_single_probe(const uint8_t move_value) {
@@ -49,7 +49,7 @@ inline bool G38_run_probe() {
#if MULTIPLE_PROBING > 1
// Get direction of move and retract
xyz_float_t retract_mm;
LOOP_LINEAR_AXES(i) {
LOOP_NUM_AXES(i) {
const float dist = destination[i] - current_position[i];
retract_mm[i] = ABS(dist) < G38_MINIMUM_MOVE ? 0 : home_bump_mm((AxisEnum)i) * (dist > 0 ? -1 : 1);
}
@@ -119,7 +119,7 @@ void GcodeSuite::G38(const int8_t subcode) {
;
// If any axis has enough movement, do the move
LOOP_LINEAR_AXES(i)
LOOP_NUM_AXES(i)
if (ABS(destination[i] - current_position[i]) >= G38_MINIMUM_MOVE) {
if (!parser.seenval('F')) feedrate_mm_s = homing_feedrate((AxisEnum)i);
// If G38.2 fails throw an error

View File

@@ -0,0 +1,57 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
*
*/
/**
* M102.cpp - Configure Bed Distance Sensor
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(BD_SENSOR)
#include "../gcode.h"
#include "../../feature/bedlevel/bdl/bdl.h"
/**
* M102: Configure the Bed Distance Sensor
*
* M102 S<10ths> : Set adjustable Z height in 10ths of a mm (e.g., 'M102 S4' enables adjusting for Z <= 0.4mm.)
* M102 S0 : Disable adjustable Z height.
*
* Negative S values are commands:
* M102 S-1 : Read sensor information
* M102 S-5 : Read raw Calibration data
* M102 S-6 : Start Calibration
*/
void GcodeSuite::M102() {
if (parser.seenval('S'))
bdl.config_state = parser.value_int();
else
M102_report();
}
void GcodeSuite::M102_report(const bool forReplay/*=true*/) {
report_heading(forReplay, F("Bed Distance Sensor"));
SERIAL_ECHOLNPGM(" M102 S", bdl.config_state);
}
#endif // BD_SENSOR

View File

@@ -28,13 +28,33 @@
#include "../../module/motion.h"
#include "../../module/probe.h"
#ifdef BLTOUCH_HS_MODE
#include "../../feature/bltouch.h"
#endif
/**
* M401: Deploy and activate the Z probe
*
* With BLTOUCH_HS_MODE:
* H Report the current BLTouch HS mode state and exit
* S<bool> Set High Speed (HS) Mode and exit without deploy
*/
void GcodeSuite::M401() {
probe.deploy();
TERN_(PROBE_TARE, probe.tare());
report_current_position();
const bool seenH = parser.seen_test('H'),
seenS = parser.seen('S');
if (seenH || seenS) {
#ifdef BLTOUCH_HS_MODE
if (seenS) bltouch.high_speed_mode = parser.value_bool();
SERIAL_ECHO_START();
SERIAL_ECHOPGM("BLTouch HS mode ");
serialprintln_onoff(bltouch.high_speed_mode);
#endif
}
else {
probe.deploy();
TERN_(PROBE_TARE, probe.tare());
report_current_position();
}
}
/**

View File

@@ -0,0 +1,99 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
*
*/
/**
* M423.cpp - X-Axis Twist Compensation
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
#include "../gcode.h"
#include "../../feature/x_twist.h"
#include "../../module/probe.h"
/**
* M423: Set a Z offset for X-Twist (added to the mesh on future G29).
* M423 [R] [A<startx>] [I<interval>] [X<index> Z<offset>]
*
* R - Reset the twist compensation data
* A<linear> - Set the X twist starting X position
* E<linear> - Set the X twist ending X position
* I<linear> - Set the X twist X-spacing directly
* X<index> - Index of a Z value in the list
* Z<linear> - A Z value to set
*/
void GcodeSuite::M423() {
bool do_report = true;
float new_spacing = 0;
if (parser.seen_test('R')) {
do_report = false;
xatc.reset();
}
if (parser.seenval('A')) {
do_report = false;
xatc.start = parser.value_float();
new_spacing = (probe.max_x() - xatc.start) / (XATC_MAX_POINTS - 1);
}
if (parser.seenval('E')) {
do_report = false;
new_spacing = (parser.value_float() - xatc.start) / (XATC_MAX_POINTS - 1);
}
else if (parser.seenval('I')) {
do_report = false;
new_spacing = parser.value_float();
}
if (new_spacing) xatc.spacing = new_spacing;
if (parser.seenval('X')) {
do_report = false;
const int8_t x = parser.value_int();
if (!WITHIN(x, 0, XATC_MAX_POINTS - 1))
SERIAL_ECHOLNPGM("?(X) out of range (0..", XATC_MAX_POINTS - 1, ").");
else {
if (parser.seenval('Z'))
xatc.z_offset[x] = parser.value_linear_units();
else
SERIAL_ECHOLNPGM("?(Z) required.");
}
}
if (do_report) M423_report();
}
void GcodeSuite::M423_report(const bool forReplay/*=true*/) {
report_heading(forReplay, F("X-Twist Correction"));
SERIAL_ECHOLNPGM(" M423 A", xatc.start, " I", xatc.spacing);
LOOP_L_N(x, XATC_MAX_POINTS) {
const float z = xatc.z_offset[x];
SERIAL_ECHOPGM(" M423 X", x, " Z");
serial_offset(isnan(z) ? 0 : z);
SERIAL_EOL();
}
}
#endif // X_AXIS_TWIST_COMPENSATION

View File

@@ -84,7 +84,7 @@ void GcodeSuite::M851() {
}
void GcodeSuite::M851_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, PSTR(STR_Z_PROBE_OFFSET));
report_heading_etc(forReplay, F(STR_Z_PROBE_OFFSET));
SERIAL_ECHOPGM_P(
#if HAS_PROBE_XY_OFFSET
PSTR(" M851 X"), LINEAR_UNIT(probe.offset_xy.x),

View File

@@ -32,13 +32,13 @@ mpe_settings_t mpe_settings;
inline void mpe_settings_report() {
SERIAL_ECHO_MSG("Magnetic Parking Extruder");
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("L: Left parking :", mpe_settings.parking_xpos[0]);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("R: Right parking :", mpe_settings.parking_xpos[1]);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("I: Grab Offset :", mpe_settings.grab_distance);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate)));
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate)));
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("D: Distance trav.:", mpe_settings.travel_distance);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("C: Compenstion :", mpe_settings.compensation_factor);
SERIAL_ECHO_MSG("L: Left parking :", mpe_settings.parking_xpos[0]);
SERIAL_ECHO_MSG("R: Right parking :", mpe_settings.parking_xpos[1]);
SERIAL_ECHO_MSG("I: Grab Offset :", mpe_settings.grab_distance);
SERIAL_ECHO_MSG("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate)));
SERIAL_ECHO_MSG("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate)));
SERIAL_ECHO_MSG("D: Distance trav.:", mpe_settings.travel_distance);
SERIAL_ECHO_MSG("C: Compenstion :", mpe_settings.compensation_factor);
}
void mpe_settings_init() {