From 83c83e31279192e11abff1266d54393df27ce708 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 10 Mar 2018 05:33:08 -0600 Subject: [PATCH 1/2] Update Marlin G-codes summary --- Marlin/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b3e0ff449..5913c8f2e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -89,7 +89,7 @@ * M24 - Start/resume SD print. (Requires SDSUPPORT) * M25 - Pause SD print. (Requires SDSUPPORT) * M26 - Set SD position in bytes: "M26 S12345". (Requires SDSUPPORT) - * M27 - Report SD print status. (Requires SDSUPPORT) Or, with 'S' sets the SD status auto-report interval. (Requires AUTO_REPORT_SD_STATUS) + * M27 - Report SD print status. (Requires SDSUPPORT) Or, with 'S' set the SD status auto-report interval. (Requires AUTO_REPORT_SD_STATUS) * M28 - Start SD write: "M28 /path/file.gco". (Requires SDSUPPORT) * M29 - Stop SD write. (Requires SDSUPPORT) * M30 - Delete file from SD: "M30 /path/file.gco" @@ -134,7 +134,7 @@ * M119 - Report endstops status. * M120 - Enable endstops detection. * M121 - Disable endstops detection. - * M122 - Debug stepper (Requires HAVE_TMC2130) + * M122 - Debug stepper (Requires HAVE_TMC2130 or HAVE_TMC2208) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * M126 - Solenoid Air Valve Open. (Requires BARICUDA) * M127 - Solenoid Air Valve Closed. (Requires BARICUDA) @@ -203,9 +203,9 @@ * M540 - Enable/disable SD card abort on endstop hit: "M540 S". (Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) * M600 - Pause for filament change: "M600 X Y Z E L". (Requires ADVANCED_PAUSE_FEATURE) * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) + * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) * M665 - Set delta configurations: "M665 L R S A B C I J K" (Requires DELTA) - * M666 - Set delta endstop adjustment. (Requires DELTA) - * M605 - Set dual x-carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) + * M666 - Set/get 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.) From e8fc0e9a570d0116f8ee45f5badcf839d385940e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 10 Mar 2018 05:12:57 -0600 Subject: [PATCH 2/2] Move [xyz]_endstop_adj to Endstops class --- Marlin/Marlin.h | 10 ------ Marlin/Marlin_main.cpp | 63 +++++++++++++++++++--------------- Marlin/configuration_store.cpp | 24 ++++++------- Marlin/endstops.cpp | 26 ++++++++------ Marlin/endstops.h | 27 ++++++++++----- 5 files changed, 82 insertions(+), 68 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 524a0cac7..3cbf06541 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -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); diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 5913c8f2e..56a5be713 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -205,7 +205,7 @@ * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) * M665 - Set delta configurations: "M665 L R S A B C I J K" (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) diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index fbde923ea..1d78a6a74 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -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 diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 6dc0b9c9f..a7edfa4b9 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -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... diff --git a/Marlin/endstops.h b/Marlin/endstops.h index e60132d6e..96cb3d089 100644 --- a/Marlin/endstops.h +++ b/Marlin/endstops.h @@ -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__