Move [xyz]_endstop_adj to Endstops class
This commit is contained in:
parent
83c83e3127
commit
e8fc0e9a57
@ -386,16 +386,6 @@ void report_current_position();
|
||||
void set_z_fade_height(const float zfh, const bool do_report=true);
|
||||
#endif
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
extern float x_endstop_adj;
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
extern float y_endstop_adj;
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
extern float z_endstop_adj;
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
extern float zprobe_zoffset;
|
||||
bool set_probe_deployed(const bool deploy);
|
||||
|
@ -205,7 +205,7 @@
|
||||
* M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
|
||||
* M605 - Set Dual X-Carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
|
||||
* M665 - Set delta configurations: "M665 L<diagonal rod> R<delta radius> S<segments/s> A<rod A trim mm> B<rod B trim mm> C<rod C trim mm> I<tower A trim angle> J<tower B trim angle> K<tower C trim angle>" (Requires DELTA)
|
||||
* M666 - Set/get offsets for delta (Requires DELTA) or dual endstops (Requires [XYZ]_DUAL_ENDSTOPS).
|
||||
* M666 - Set/get endstop offsets for delta (Requires DELTA) or dual endstops (Requires [XYZ]_DUAL_ENDSTOPS).
|
||||
* M701 - Load filament (requires FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
* M702 - Unload filament (requires FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
* M851 - Set Z probe's Z offset in current units. (Negative = below the nozzle.)
|
||||
@ -565,16 +565,6 @@ uint8_t target_extruder;
|
||||
#define ADJUST_DELTA(V) NOOP
|
||||
#endif
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
float x_endstop_adj; // Initialized by settings.load()
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
float y_endstop_adj; // Initialized by settings.load()
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
float z_endstop_adj; // Initialized by settings.load()
|
||||
#endif
|
||||
|
||||
// Extruder offsets
|
||||
#if HOTENDS > 1
|
||||
float hotend_offset[XYZ][HOTENDS]; // Initialized by settings.load()
|
||||
@ -3030,8 +3020,8 @@ static void homeaxis(const AxisEnum axis) {
|
||||
const bool pos_dir = axis_home_dir > 0;
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
if (axis == X_AXIS) {
|
||||
const bool lock_x1 = pos_dir ? (x_endstop_adj > 0) : (x_endstop_adj < 0);
|
||||
const float adj = FABS(x_endstop_adj);
|
||||
const bool lock_x1 = pos_dir ? (endstops.x_endstop_adj > 0) : (endstops.x_endstop_adj < 0);
|
||||
const float adj = FABS(endstops.x_endstop_adj);
|
||||
if (lock_x1) stepper.set_x_lock(true); else stepper.set_x2_lock(true);
|
||||
do_homing_move(axis, pos_dir ? -adj : adj);
|
||||
if (lock_x1) stepper.set_x_lock(false); else stepper.set_x2_lock(false);
|
||||
@ -3040,8 +3030,8 @@ static void homeaxis(const AxisEnum axis) {
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
if (axis == Y_AXIS) {
|
||||
const bool lock_y1 = pos_dir ? (y_endstop_adj > 0) : (y_endstop_adj < 0);
|
||||
const float adj = FABS(y_endstop_adj);
|
||||
const bool lock_y1 = pos_dir ? (endstops.y_endstop_adj > 0) : (endstops.y_endstop_adj < 0);
|
||||
const float adj = FABS(endstops.y_endstop_adj);
|
||||
if (lock_y1) stepper.set_y_lock(true); else stepper.set_y2_lock(true);
|
||||
do_homing_move(axis, pos_dir ? -adj : adj);
|
||||
if (lock_y1) stepper.set_y_lock(false); else stepper.set_y2_lock(false);
|
||||
@ -3050,8 +3040,8 @@ static void homeaxis(const AxisEnum axis) {
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
if (axis == Z_AXIS) {
|
||||
const bool lock_z1 = pos_dir ? (z_endstop_adj > 0) : (z_endstop_adj < 0);
|
||||
const float adj = FABS(z_endstop_adj);
|
||||
const bool lock_z1 = pos_dir ? (endstops.z_endstop_adj > 0) : (endstops.z_endstop_adj < 0);
|
||||
const float adj = FABS(endstops.z_endstop_adj);
|
||||
if (lock_z1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
|
||||
do_homing_move(axis, pos_dir ? -adj : adj);
|
||||
if (lock_z1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
|
||||
@ -9021,26 +9011,45 @@ inline void gcode_M205() {
|
||||
#elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
||||
|
||||
/**
|
||||
* M666: For Z Dual Endstop setup, set z axis offset to the z2 axis.
|
||||
* M666: Set Dual Endstops offsets for X, Y, and/or Z.
|
||||
* With no parameters report current offsets.
|
||||
*/
|
||||
inline void gcode_M666() {
|
||||
SERIAL_ECHOPGM("Dual Endstop Adjustment (mm): ");
|
||||
bool report = true;
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
if (parser.seen('X')) x_endstop_adj = parser.value_linear_units();
|
||||
SERIAL_ECHOPAIR(" X", x_endstop_adj);
|
||||
if (parser.seenval('X')) {
|
||||
endstops.x_endstop_adj = parser.value_linear_units();
|
||||
report = false;
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
if (parser.seen('Y')) y_endstop_adj = parser.value_linear_units();
|
||||
SERIAL_ECHOPAIR(" Y", y_endstop_adj);
|
||||
if (parser.seenval('Y')) {
|
||||
endstops.y_endstop_adj = parser.value_linear_units();
|
||||
report = false;
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
if (parser.seen('Z')) z_endstop_adj = parser.value_linear_units();
|
||||
SERIAL_ECHOPAIR(" Z", z_endstop_adj);
|
||||
if (parser.seenval('Z')) {
|
||||
endstops.z_endstop_adj = parser.value_linear_units();
|
||||
report = false;
|
||||
}
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
if (report) {
|
||||
SERIAL_ECHOPGM("Dual Endstop Adjustment (mm): ");
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR(" X", endstops.x_endstop_adj);
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR(" Y", endstops.y_endstop_adj);
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR(" Z", endstops.z_endstop_adj);
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !DELTA && Z_DUAL_ENDSTOPS
|
||||
#endif // X_DUAL_ENDSTOPS || Y_DUAL_ENDSTOPS || Z_DUAL_ENDSTOPS
|
||||
|
||||
#if ENABLED(FWRETRACT)
|
||||
|
||||
|
@ -546,19 +546,19 @@ void MarlinSettings::postprocess() {
|
||||
// Write dual endstops in X, Y, Z order. Unused = 0.0
|
||||
dummy = 0.0f;
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
EEPROM_WRITE(x_endstop_adj); // 1 float
|
||||
EEPROM_WRITE(endstops.x_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
EEPROM_WRITE(y_endstop_adj); // 1 float
|
||||
EEPROM_WRITE(endstops.y_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
EEPROM_WRITE(z_endstop_adj); // 1 float
|
||||
EEPROM_WRITE(endstops.z_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
@ -1070,17 +1070,17 @@ void MarlinSettings::postprocess() {
|
||||
_FIELD_TEST(x_endstop_adj);
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
EEPROM_READ(x_endstop_adj); // 1 float
|
||||
EEPROM_READ(endstops.x_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_READ(dummy);
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
EEPROM_READ(y_endstop_adj); // 1 float
|
||||
EEPROM_READ(endstops.y_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_READ(dummy);
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
EEPROM_READ(z_endstop_adj); // 1 float
|
||||
EEPROM_READ(endstops.z_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_READ(dummy);
|
||||
#endif
|
||||
@ -1638,7 +1638,7 @@ void MarlinSettings::reset() {
|
||||
#elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
x_endstop_adj = (
|
||||
endstops.x_endstop_adj = (
|
||||
#ifdef X_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
X_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
#else
|
||||
@ -1647,7 +1647,7 @@ void MarlinSettings::reset() {
|
||||
);
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
y_endstop_adj = (
|
||||
endstops.y_endstop_adj = (
|
||||
#ifdef Y_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
Y_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
#else
|
||||
@ -1656,7 +1656,7 @@ void MarlinSettings::reset() {
|
||||
);
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
z_endstop_adj = (
|
||||
endstops.z_endstop_adj = (
|
||||
#ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
Z_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
#else
|
||||
@ -2140,13 +2140,13 @@ void MarlinSettings::reset() {
|
||||
CONFIG_ECHO_START;
|
||||
SERIAL_ECHOPGM(" M666");
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR(" X", LINEAR_UNIT(x_endstop_adj));
|
||||
SERIAL_ECHOPAIR(" X", LINEAR_UNIT(endstops.x_endstop_adj));
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(y_endstop_adj));
|
||||
SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(endstops.y_endstop_adj));
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(z_endstop_adj));
|
||||
SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(endstops.z_endstop_adj));
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
#endif // DELTA
|
||||
|
@ -41,18 +41,24 @@ Endstops endstops;
|
||||
bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load()
|
||||
volatile char Endstops::endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
||||
uint16_t
|
||||
#else
|
||||
byte
|
||||
#endif
|
||||
Endstops::current_endstop_bits = 0,
|
||||
Endstops::old_endstop_bits = 0;
|
||||
Endstops::esbits_t Endstops::current_endstop_bits = 0,
|
||||
Endstops::old_endstop_bits = 0;
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
volatile bool Endstops::z_probe_enabled = false;
|
||||
#endif
|
||||
|
||||
// Initialized by settings.load()
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
float Endstops::x_endstop_adj;
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
float Endstops::y_endstop_adj;
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
float Endstops::z_endstop_adj;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Class and Instance Methods
|
||||
*/
|
||||
@ -269,7 +275,7 @@ void Endstops::M119() {
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
void Endstops::test_dual_x_endstops(const EndstopEnum es1, const EndstopEnum es2) {
|
||||
byte x_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for X, bit 1 for X2
|
||||
const byte x_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for X, bit 1 for X2
|
||||
if (x_test && stepper.current_block->steps[X_AXIS] > 0) {
|
||||
SBI(endstop_hit_bits, X_MIN);
|
||||
if (!stepper.performing_homing || (x_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
|
||||
@ -279,7 +285,7 @@ void Endstops::M119() {
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
void Endstops::test_dual_y_endstops(const EndstopEnum es1, const EndstopEnum es2) {
|
||||
byte y_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for Y, bit 1 for Y2
|
||||
const byte y_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for Y, bit 1 for Y2
|
||||
if (y_test && stepper.current_block->steps[Y_AXIS] > 0) {
|
||||
SBI(endstop_hit_bits, Y_MIN);
|
||||
if (!stepper.performing_homing || (y_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
|
||||
@ -289,7 +295,7 @@ void Endstops::M119() {
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
void Endstops::test_dual_z_endstops(const EndstopEnum es1, const EndstopEnum es2) {
|
||||
byte z_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for Z, bit 1 for Z2
|
||||
const byte z_test = TEST_ENDSTOP(es1) | (TEST_ENDSTOP(es2) << 1); // bit 0 for Z, bit 1 for Z2
|
||||
if (z_test && stepper.current_block->steps[Z_AXIS] > 0) {
|
||||
SBI(endstop_hit_bits, Z_MIN);
|
||||
if (!stepper.performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
|
||||
|
@ -21,11 +21,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* endstops.h - manages endstops
|
||||
* endstops.h - manages endstops
|
||||
*/
|
||||
|
||||
#ifndef ENDSTOPS_H
|
||||
#define ENDSTOPS_H
|
||||
#ifndef __ENDSTOPS_H__
|
||||
#define __ENDSTOPS_H__
|
||||
|
||||
#include "enum.h"
|
||||
#include "MarlinConfig.h"
|
||||
@ -38,11 +38,21 @@ class Endstops {
|
||||
static volatile char endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
||||
static uint16_t
|
||||
typedef uint16_t esbits_t;
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
static float x_endstop_adj;
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
static float y_endstop_adj;
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
static float z_endstop_adj;
|
||||
#endif
|
||||
#else
|
||||
static byte
|
||||
typedef byte esbits_t;
|
||||
#endif
|
||||
current_endstop_bits, old_endstop_bits;
|
||||
|
||||
static esbits_t current_endstop_bits, old_endstop_bits;
|
||||
|
||||
Endstops() {
|
||||
enable_globally(
|
||||
@ -57,7 +67,7 @@ class Endstops {
|
||||
/**
|
||||
* Initialize the endstop pins
|
||||
*/
|
||||
void init();
|
||||
static void init();
|
||||
|
||||
/**
|
||||
* Update the endstops bits from the pins
|
||||
@ -113,5 +123,4 @@ extern Endstops endstops;
|
||||
#define ENDSTOPS_ENABLED endstops.enabled
|
||||
#endif
|
||||
|
||||
|
||||
#endif // ENDSTOPS_H
|
||||
#endif // __ENDSTOPS_H__
|
||||
|
Loading…
Reference in New Issue
Block a user