Browse Source

Misc Power Loss cleanup

vanilla_fb_2.0.x
Scott Lahteine 3 years ago
parent
commit
45d3866f97
  1. 27
      Marlin/src/feature/powerloss.cpp
  2. 5
      Marlin/src/feature/powerloss.h

27
Marlin/src/feature/powerloss.cpp

@ -66,9 +66,6 @@ PrintJobRecovery recovery;
#ifndef POWER_LOSS_PURGE_LEN #ifndef POWER_LOSS_PURGE_LEN
#define POWER_LOSS_PURGE_LEN 0 #define POWER_LOSS_PURGE_LEN 0
#endif #endif
#ifndef POWER_LOSS_ZRAISE
#define POWER_LOSS_ZRAISE 2 // Move on loss with backup power, or on resume without it
#endif
#if DISABLED(BACKUP_POWER_SUPPLY) #if DISABLED(BACKUP_POWER_SUPPLY)
#undef POWER_LOSS_RETRACT_LEN // No retract at outage without backup power #undef POWER_LOSS_RETRACT_LEN // No retract at outage without backup power
@ -256,7 +253,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
// Raise the Z axis now // Raise the Z axis now
if (zraise) { if (zraise) {
char cmd[20], str_1[16]; char cmd[20], str_1[16];
sprintf_P(cmd, PSTR("G0 Z%s"), dtostrf(zraise, 1, 3, str_1)); sprintf_P(cmd, PSTR("G0Z%s"), dtostrf(zraise, 1, 3, str_1));
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
} }
#else #else
@ -348,7 +345,7 @@ void PrintJobRecovery::resume() {
const celsius_t bt = info.target_temperature_bed; const celsius_t bt = info.target_temperature_bed;
if (bt) { if (bt) {
// Restore the bed temperature // Restore the bed temperature
sprintf_P(cmd, PSTR("M190 S%i"), bt); sprintf_P(cmd, PSTR("M190S%i"), bt);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
} }
#endif #endif
@ -359,10 +356,10 @@ void PrintJobRecovery::resume() {
const celsius_t et = info.target_temperature[e]; const celsius_t et = info.target_temperature[e];
if (et) { if (et) {
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
sprintf_P(cmd, PSTR("T%i S"), e); sprintf_P(cmd, PSTR("T%iS"), e);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
#endif #endif
sprintf_P(cmd, PSTR("M109 S%i"), et); sprintf_P(cmd, PSTR("M109S%i"), et);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
} }
} }
@ -370,7 +367,7 @@ void PrintJobRecovery::resume() {
// //
// Home the axes that can safely be homed, and // Home the axes that can safely be homed, and
// establish the current position as best we can // establish the current position as best we can.
// //
#if Z_HOME_DIR > 0 #if Z_HOME_DIR > 0
@ -380,7 +377,7 @@ void PrintJobRecovery::resume() {
"G28R0" // Home all axes (no raise) "G28R0" // Home all axes (no raise)
)); ));
#else // "G92.9 E0 ..." #else
// If a Z raise occurred at outage restore Z, otherwise raise Z now // If a Z raise occurred at outage restore Z, otherwise raise Z now
sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1)); sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1));
@ -475,7 +472,7 @@ void PrintJobRecovery::resume() {
// Un-retract if there was a retract at outage // Un-retract if there was a retract at outage
#if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0 #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0
gcode.process_subcommands_now_P(PSTR("G1 E" STRINGIFY(POWER_LOSS_RETRACT_LEN) " F3000")); gcode.process_subcommands_now_P(PSTR("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000"));
#endif #endif
// Additional purge on resume if configured // Additional purge on resume if configured
@ -488,8 +485,8 @@ void PrintJobRecovery::resume() {
gcode.process_subcommands_now_P(PSTR("G12")); gcode.process_subcommands_now_P(PSTR("G12"));
#endif #endif
// Move back to the saved XY // Move back over to the saved XY
sprintf_P(cmd, PSTR("G1 X%s Y%s F3000"), sprintf_P(cmd, PSTR("G1X%sY%sF3000"),
dtostrf(info.current_position.x, 1, 3, str_1), dtostrf(info.current_position.x, 1, 3, str_1),
dtostrf(info.current_position.y, 1, 3, str_2) dtostrf(info.current_position.y, 1, 3, str_2)
); );
@ -506,11 +503,11 @@ void PrintJobRecovery::resume() {
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
// Restore the feedrate // Restore the feedrate
sprintf_P(cmd, PSTR("G1 F%d"), info.feedrate); sprintf_P(cmd, PSTR("G1F%d"), info.feedrate);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
// Restore E position with G92.9 // Restore E position with G92.9
sprintf_P(cmd, PSTR("G92.9 E%s"), dtostrf(info.current_position.e, 1, 3, str_1)); sprintf_P(cmd, PSTR("G92.9E%s"), dtostrf(info.current_position.e, 1, 3, str_1));
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat); TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat);
@ -535,7 +532,7 @@ void PrintJobRecovery::resume() {
char *fn = info.sd_filename; char *fn = info.sd_filename;
sprintf_P(cmd, M23_STR, fn); sprintf_P(cmd, M23_STR, fn);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed); sprintf_P(cmd, PSTR("M24S%ldT%ld"), resume_sdpos, info.print_job_elapsed);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
TERN_(DEBUG_POWER_LOSS_RECOVERY, marlin_debug_flags = old_flags); TERN_(DEBUG_POWER_LOSS_RECOVERY, marlin_debug_flags = old_flags);

5
Marlin/src/feature/powerloss.h

@ -42,6 +42,10 @@
#define POWER_LOSS_STATE HIGH #define POWER_LOSS_STATE HIGH
#endif #endif
#ifndef POWER_LOSS_ZRAISE
#define POWER_LOSS_ZRAISE 2
#endif
//#define DEBUG_POWER_LOSS_RECOVERY //#define DEBUG_POWER_LOSS_RECOVERY
//#define SAVE_EACH_CMD_MODE //#define SAVE_EACH_CMD_MODE
//#define SAVE_INFO_INTERVAL_MS 0 //#define SAVE_INFO_INTERVAL_MS 0
@ -52,6 +56,7 @@ typedef struct {
// Machine state // Machine state
xyze_pos_t current_position; xyze_pos_t current_position;
uint16_t feedrate; uint16_t feedrate;
float zraise; float zraise;
// Repeat information // Repeat information

Loading…
Cancel
Save