Move z_endstop_adj to Endstops

This commit is contained in:
Scott Lahteine 2017-09-18 05:56:10 -05:00
parent 2e20c53c9d
commit 64dfb46461
7 changed files with 16 additions and 19 deletions

View File

@ -179,10 +179,6 @@ volatile bool wait_for_heatup = true;
millis_t max_inactive_time = 0, millis_t max_inactive_time = 0,
stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL; stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
#if ENABLED(Z_DUAL_ENDSTOPS)
float z_endstop_adj;
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #if ENABLED(FILAMENT_RUNOUT_SENSOR)
static bool filament_ran_out = false; static bool filament_ran_out = false;
#endif #endif

View File

@ -190,10 +190,6 @@ extern volatile bool wait_for_heatup;
// Inactivity shutdown timer // Inactivity shutdown timer
extern millis_t max_inactive_time, stepper_inactive_time; extern millis_t max_inactive_time, stepper_inactive_time;
#if ENABLED(Z_DUAL_ENDSTOPS)
extern float z_endstop_adj;
#endif
#if HAS_SERVOS #if HAS_SERVOS
#include "HAL/servo.h" #include "HAL/servo.h"
extern HAL_SERVO_LIB servo[NUM_SERVOS]; extern HAL_SERVO_LIB servo[NUM_SERVOS];

View File

@ -64,14 +64,14 @@
#elif ENABLED(Z_DUAL_ENDSTOPS) // !DELTA && ENABLED(Z_DUAL_ENDSTOPS) #elif ENABLED(Z_DUAL_ENDSTOPS) // !DELTA && ENABLED(Z_DUAL_ENDSTOPS)
#include "../../Marlin.h" // for z_endstop_adj #include "../../module/endstops.h"
/** /**
* M666: For Z Dual Endstop setup, set z axis offset to the z2 axis. * M666: For Z Dual Endstop setup, set z axis offset to the z2 axis.
*/ */
void GcodeSuite::M666() { void GcodeSuite::M666() {
if (parser.seen('Z')) z_endstop_adj = parser.value_linear_units(); if (parser.seen('Z')) endstops.z_endstop_adj = parser.value_linear_units();
SERIAL_ECHOLNPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj); SERIAL_ECHOLNPAIR("Z Endstop Adjustment set to (mm):", endstops.z_endstop_adj);
} }
#endif #endif

View File

@ -103,7 +103,7 @@
* --- M665 Z delta_tower_angle_trim[C] (float) is always 0.0 * --- M665 Z delta_tower_angle_trim[C] (float) is always 0.0
* *
* Z_DUAL_ENDSTOPS: 48 bytes * Z_DUAL_ENDSTOPS: 48 bytes
* 348 M666 Z z_endstop_adj (float) * 348 M666 Z endstops.z_endstop_adj (float)
* --- dummy data (float x11) * --- dummy data (float x11)
* *
* ULTIPANEL: 6 bytes * ULTIPANEL: 6 bytes
@ -426,7 +426,7 @@ void MarlinSettings::postprocess() {
dummy = 0.0f; dummy = 0.0f;
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
#elif ENABLED(Z_DUAL_ENDSTOPS) #elif ENABLED(Z_DUAL_ENDSTOPS)
EEPROM_WRITE(z_endstop_adj); // 1 float EEPROM_WRITE(endstops.z_endstop_adj); // 1 float
dummy = 0.0f; dummy = 0.0f;
for (uint8_t q = 11; q--;) EEPROM_WRITE(dummy); for (uint8_t q = 11; q--;) EEPROM_WRITE(dummy);
#else #else
@ -811,7 +811,7 @@ void MarlinSettings::postprocess() {
dummy = 0.0f; dummy = 0.0f;
for (uint8_t q=3; q--;) EEPROM_READ(dummy); for (uint8_t q=3; q--;) EEPROM_READ(dummy);
#elif ENABLED(Z_DUAL_ENDSTOPS) #elif ENABLED(Z_DUAL_ENDSTOPS)
EEPROM_READ(z_endstop_adj); EEPROM_READ(endstops.z_endstop_adj); // 1 float
dummy = 0.0f; dummy = 0.0f;
for (uint8_t q=11; q--;) EEPROM_READ(dummy); for (uint8_t q=11; q--;) EEPROM_READ(dummy);
#else #else
@ -1203,7 +1203,7 @@ void MarlinSettings::reset() {
#elif ENABLED(Z_DUAL_ENDSTOPS) #elif ENABLED(Z_DUAL_ENDSTOPS)
z_endstop_adj = endstops.z_endstop_adj =
#ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT #ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
Z_DUAL_ENDSTOPS_ADJUSTMENT Z_DUAL_ENDSTOPS_ADJUSTMENT
#else #else
@ -1621,7 +1621,7 @@ void MarlinSettings::reset() {
SERIAL_ECHOLNPGM("Z2 Endstop adjustment:"); SERIAL_ECHOLNPGM("Z2 Endstop adjustment:");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOLNPAIR(" M666 Z", LINEAR_UNIT(z_endstop_adj)); SERIAL_ECHOLNPAIR(" M666 Z", LINEAR_UNIT(endstops.z_endstop_adj));
#endif // DELTA #endif // DELTA
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)

View File

@ -54,6 +54,10 @@ volatile char Endstops::endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_P
volatile bool Endstops::z_probe_enabled = false; volatile bool Endstops::z_probe_enabled = false;
#endif #endif
#if ENABLED(Z_DUAL_ENDSTOPS)
float Endstops::z_endstop_adj;
#endif
/** /**
* Class and Instance Methods * Class and Instance Methods
*/ */

View File

@ -50,6 +50,7 @@ class Endstops {
static volatile char endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value static volatile char endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
#if ENABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS)
static float z_endstop_adj;
typedef uint16_t esbits_t; typedef uint16_t esbits_t;
#else #else
typedef byte esbits_t; typedef byte esbits_t;

View File

@ -1099,14 +1099,14 @@ void homeaxis(const AxisEnum axis) {
#if ENABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) { if (axis == Z_AXIS) {
float adj = FABS(z_endstop_adj); float adj = FABS(endstops.z_endstop_adj);
bool lockZ1; bool lockZ1;
if (axis_home_dir > 0) { if (axis_home_dir > 0) {
adj = -adj; adj = -adj;
lockZ1 = (z_endstop_adj > 0); lockZ1 = (endstops.z_endstop_adj > 0);
} }
else else
lockZ1 = (z_endstop_adj < 0); lockZ1 = (endstops.z_endstop_adj < 0);
if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true); if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);