Followup to hotend_offset[Z] patch
This commit is contained in:
parent
e2b8fc4f17
commit
d1c9517903
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
|
|
||||||
#include "../gcode.h"
|
#include "../gcode.h"
|
||||||
#include "../../module/motion.h"
|
#include "../../module/motion.h"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
* T<tool>
|
* T<tool>
|
||||||
* X<xoffset>
|
* X<xoffset>
|
||||||
* Y<yoffset>
|
* Y<yoffset>
|
||||||
* Z<zoffset> - Available with DUAL_X_CARRIAGE, SWITCHING_NOZZLE and PARKING_EXTRUDER
|
* Z<zoffset>
|
||||||
*/
|
*/
|
||||||
void GcodeSuite::M218() {
|
void GcodeSuite::M218() {
|
||||||
if (get_target_extruder_from_command() || target_extruder == 0) return;
|
if (get_target_extruder_from_command() || target_extruder == 0) return;
|
||||||
@ -51,13 +51,10 @@ void GcodeSuite::M218() {
|
|||||||
hotend_offset[Y_AXIS][target_extruder] = parser.value_linear_units();
|
hotend_offset[Y_AXIS][target_extruder] = parser.value_linear_units();
|
||||||
report = false;
|
report = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAS_HOTEND_OFFSET_Z
|
|
||||||
if (parser.seenval('Z')) {
|
if (parser.seenval('Z')) {
|
||||||
hotend_offset[Z_AXIS][target_extruder] = parser.value_linear_units();
|
hotend_offset[Z_AXIS][target_extruder] = parser.value_linear_units();
|
||||||
report = false;
|
report = false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (report) {
|
if (report) {
|
||||||
SERIAL_ECHO_START();
|
SERIAL_ECHO_START();
|
||||||
@ -67,10 +64,8 @@ void GcodeSuite::M218() {
|
|||||||
SERIAL_ECHO(hotend_offset[X_AXIS][e]);
|
SERIAL_ECHO(hotend_offset[X_AXIS][e]);
|
||||||
SERIAL_CHAR(',');
|
SERIAL_CHAR(',');
|
||||||
SERIAL_ECHO(hotend_offset[Y_AXIS][e]);
|
SERIAL_ECHO(hotend_offset[Y_AXIS][e]);
|
||||||
#if HAS_HOTEND_OFFSET_Z
|
|
||||||
SERIAL_CHAR(',');
|
SERIAL_CHAR(',');
|
||||||
SERIAL_ECHO(hotend_offset[Z_AXIS][e]);
|
SERIAL_ECHO(hotend_offset[Z_AXIS][e]);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
@ -81,4 +76,4 @@ void GcodeSuite::M218() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HOTENDS > 1
|
#endif // HAS_HOTEND_OFFSET
|
||||||
|
@ -65,7 +65,7 @@ void GcodeSuite::M125() {
|
|||||||
// Lift Z axis
|
// Lift Z axis
|
||||||
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
|
||||||
|
|
||||||
#if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
|
#if HAS_HOTEND_OFFSET && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
|
||||||
park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
|
park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
|
||||||
park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
|
park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,7 +87,7 @@ void GcodeSuite::M600() {
|
|||||||
if (parser.seenval('X')) park_point.x = parser.linearval('X');
|
if (parser.seenval('X')) park_point.x = parser.linearval('X');
|
||||||
if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
|
if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
|
||||||
|
|
||||||
#if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
|
#if HAS_HOTEND_OFFSET && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
|
||||||
park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
|
park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
|
||||||
park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
|
park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -458,6 +458,8 @@
|
|||||||
|
|
||||||
#define DO_SWITCH_EXTRUDER (ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR))
|
#define DO_SWITCH_EXTRUDER (ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR))
|
||||||
|
|
||||||
|
#define HAS_HOTEND_OFFSET (HOTENDS > 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DISTINCT_E_FACTORS affects how some E factors are accessed
|
* DISTINCT_E_FACTORS affects how some E factors are accessed
|
||||||
*/
|
*/
|
||||||
|
@ -413,7 +413,6 @@
|
|||||||
/**
|
/**
|
||||||
* Default hotend offsets, if not defined
|
* Default hotend offsets, if not defined
|
||||||
*/
|
*/
|
||||||
#define HAS_HOTEND_OFFSET_Z (HOTENDS > 1 && (ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)))
|
|
||||||
#if HOTENDS > 1
|
#if HOTENDS > 1
|
||||||
#ifndef HOTEND_OFFSET_X
|
#ifndef HOTEND_OFFSET_X
|
||||||
#define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
|
#define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
|
||||||
@ -421,8 +420,8 @@
|
|||||||
#ifndef HOTEND_OFFSET_Y
|
#ifndef HOTEND_OFFSET_Y
|
||||||
#define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
|
#define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
|
||||||
#endif
|
#endif
|
||||||
#if HAS_HOTEND_OFFSET_Z && !defined(HOTEND_OFFSET_Z)
|
#ifndef HOTEND_OFFSET_Z
|
||||||
#define HOTEND_OFFSET_Z { 0 }
|
#define HOTEND_OFFSET_Z { 0 } // Z offsets for each extruder
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ typedef struct SettingsDataStruct {
|
|||||||
|
|
||||||
float home_offset[XYZ]; // M206 XYZ
|
float home_offset[XYZ]; // M206 XYZ
|
||||||
|
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
float hotend_offset[XYZ][HOTENDS - 1]; // M218 XYZ
|
float hotend_offset[XYZ][HOTENDS - 1]; // M218 XYZ
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ void MarlinSettings::postprocess() {
|
|||||||
#endif
|
#endif
|
||||||
EEPROM_WRITE(home_offset);
|
EEPROM_WRITE(home_offset);
|
||||||
|
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
// Skip hotend 0 which must be 0
|
// Skip hotend 0 which must be 0
|
||||||
for (uint8_t e = 1; e < HOTENDS; e++)
|
for (uint8_t e = 1; e < HOTENDS; e++)
|
||||||
LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
|
LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
|
||||||
@ -1038,7 +1038,7 @@ void MarlinSettings::postprocess() {
|
|||||||
// Hotend Offsets, if any
|
// Hotend Offsets, if any
|
||||||
//
|
//
|
||||||
|
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
// Skip hotend 0 which must be 0
|
// Skip hotend 0 which must be 0
|
||||||
for (uint8_t e = 1; e < HOTENDS; e++)
|
for (uint8_t e = 1; e < HOTENDS; e++)
|
||||||
LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
|
LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
|
||||||
@ -1749,16 +1749,8 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
|||||||
ZERO(home_offset);
|
ZERO(home_offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
constexpr float tmp4[XYZ][HOTENDS] = {
|
constexpr float tmp4[XYZ][HOTENDS] = { HOTEND_OFFSET_X, HOTEND_OFFSET_Y, HOTEND_OFFSET_Z };
|
||||||
HOTEND_OFFSET_X,
|
|
||||||
HOTEND_OFFSET_Y
|
|
||||||
#ifdef HOTEND_OFFSET_Z
|
|
||||||
, HOTEND_OFFSET_Z
|
|
||||||
#else
|
|
||||||
, { 0 }
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
static_assert(
|
static_assert(
|
||||||
tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
|
tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
|
||||||
"Offsets for the first hotend must be 0.0."
|
"Offsets for the first hotend must be 0.0."
|
||||||
@ -2163,7 +2155,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
|||||||
SERIAL_ECHOLNPAIR_P(port, " Z", LINEAR_UNIT(home_offset[Z_AXIS]));
|
SERIAL_ECHOLNPAIR_P(port, " Z", LINEAR_UNIT(home_offset[Z_AXIS]));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
if (!forReplay) {
|
if (!forReplay) {
|
||||||
CONFIG_ECHO_START;
|
CONFIG_ECHO_START;
|
||||||
SERIAL_ECHOLNPGM_P(port, "Hotend offsets:");
|
SERIAL_ECHOLNPGM_P(port, "Hotend offsets:");
|
||||||
@ -2173,9 +2165,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
|||||||
SERIAL_ECHOPAIR_P(port, " M218 T", (int)e);
|
SERIAL_ECHOPAIR_P(port, " M218 T", (int)e);
|
||||||
SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(hotend_offset[X_AXIS][e]));
|
SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(hotend_offset[X_AXIS][e]));
|
||||||
SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(hotend_offset[Y_AXIS][e]));
|
SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(hotend_offset[Y_AXIS][e]));
|
||||||
#if HAS_HOTEND_OFFSET_Z
|
|
||||||
SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(hotend_offset[Z_AXIS][e]));
|
SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(hotend_offset[Z_AXIS][e]));
|
||||||
#endif
|
|
||||||
SERIAL_EOL_P(port);
|
SERIAL_EOL_P(port);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -102,7 +102,7 @@ void recalc_delta_settings() {
|
|||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
void inverse_kinematics(const float raw[XYZ]) {
|
void inverse_kinematics(const float raw[XYZ]) {
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
// Delta hotend offsets must be applied in Cartesian space with no "spoofing"
|
// Delta hotend offsets must be applied in Cartesian space with no "spoofing"
|
||||||
const float pos[XYZ] = {
|
const float pos[XYZ] = {
|
||||||
raw[X_AXIS] - hotend_offset[X_AXIS][active_extruder],
|
raw[X_AXIS] - hotend_offset[X_AXIS][active_extruder],
|
||||||
|
@ -92,7 +92,7 @@ float destination[XYZE] = { 0 };
|
|||||||
uint8_t active_extruder; // = 0;
|
uint8_t active_extruder; // = 0;
|
||||||
|
|
||||||
// Extruder offsets
|
// Extruder offsets
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
float hotend_offset[XYZ][HOTENDS]; // Initialized by settings.load()
|
float hotend_offset[XYZ][HOTENDS]; // Initialized by settings.load()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ extern int16_t feedrate_percentage;
|
|||||||
|
|
||||||
extern uint8_t active_extruder;
|
extern uint8_t active_extruder;
|
||||||
|
|
||||||
#if HOTENDS > 1
|
#if HAS_HOTEND_OFFSET
|
||||||
extern float hotend_offset[XYZ][HOTENDS];
|
extern float hotend_offset[XYZ][HOTENDS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user