Really poweroff Z motors when PSU_Delta is defined

enable/disable_z behave differently when PSU_Delta is defined.

During powerpanic and kill however we do *really* need to save energy
and poweroff the motors.

Rename enable/disable_z as poweron/poweroff_z and define some aliases so
that we can use the low-level function where needed.
This commit is contained in:
Yuri D'Elia 2020-01-27 18:50:17 +01:00
parent 59b7c21657
commit 3da20db024
2 changed files with 21 additions and 22 deletions

View file

@ -146,40 +146,39 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
#if defined(Z_AXIS_ALWAYS_ON)
#ifdef Z_DUAL_STEPPER_DRIVERS
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
#define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define disable_z() {}
#define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define poweroff_z() {}
#endif
#else
#ifdef Z_DUAL_STEPPER_DRIVERS
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
#define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#endif
#endif
#else
#define enable_z() {}
#define disable_z() {}
#define poweron_z() {}
#define poweroff_z() {}
#endif
#ifdef PSU_Delta
#ifndef PSU_Delta
#define enable_z() poweron_z()
#define disable_z() poweroff_z()
#else
void init_force_z();
void check_force_z();
#undef disable_z
#define disable_z() disable_force_z()
void disable_force_z();
#undef enable_z
#define enable_z() enable_force_z()
void enable_force_z();
void disable_force_z();
#define enable_z() enable_force_z()
#define disable_z() disable_force_z()
#endif // PSU_Delta
//#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
//#ifdef Z_DUAL_STEPPER_DRIVERS
//#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }

View file

@ -9595,7 +9595,7 @@ void kill(const char *full_screen_message, unsigned char id)
disable_x();
// SERIAL_ECHOLNPGM("kill - disable Y");
disable_y();
disable_z();
poweroff_z();
disable_e0();
disable_e1();
disable_e2();
@ -10579,7 +10579,7 @@ void uvlo_()
+ UVLO_Z_AXIS_SHIFT;
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS]/60, active_extruder);
st_synchronize();
disable_z();
poweroff_z();
// Write the file position.
eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position);
@ -10638,7 +10638,7 @@ void uvlo_()
WRITE(BEEPER,HIGH);
// All is set: with all the juice left, try to move extruder away to detach the nozzle completely from the print
enable_z();
poweron_z();
current_position[X_AXIS] = (current_position[X_AXIS] < 0.5f * (X_MIN_POS + X_MAX_POS)) ? X_MIN_POS : X_MAX_POS;
plan_buffer_line_curposXYZE(500, active_extruder);
st_synchronize();
@ -10693,7 +10693,7 @@ void uvlo_tiny()
+ UVLO_TINY_Z_AXIS_SHIFT;
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS]/60, active_extruder);
st_synchronize();
disable_z();
poweroff_z();
// Update Z position
eeprom_update_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z), current_position[Z_AXIS]);