Browse Source

Power-Loss cleanup

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
committed by Scott Lahteine
parent
commit
f3805edbd6
  1. 22
      Marlin/src/feature/powerloss.cpp
  2. 45
      Marlin/src/feature/powerloss.h

22
Marlin/src/feature/powerloss.cpp

@ -180,10 +180,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
// Machine state
info.current_position = current_position;
info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
info.zraise = zraise;
TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
#if HAS_MULTI_EXTRUDER
info.active_extruder = active_extruder;
@ -209,7 +209,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
#endif
#if HAS_LEVELING
info.leveling = planner.leveling_active;
info.flag.leveling = planner.leveling_active;
info.fade = TERN0(ENABLE_LEVELING_FADE_HEIGHT, planner.z_fade_height);
#endif
@ -220,12 +220,12 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
info.retract_hop = fwretract.current_hop;
#endif
// Relative axis modes
info.axis_relative = gcode.axis_relative;
// Elapsed print job time
info.print_job_elapsed = print_job_timer.duration();
// Relative axis modes
info.axis_relative = gcode.axis_relative;
// Misc. Marlin flags
info.flag.dryrun = !!(marlin_debug_flags & MARLIN_DEBUG_DRYRUN);
info.flag.allow_cold_extrusion = TERN0(PREVENT_COLD_EXTRUSION, thermalManager.allow_cold_extrude);
@ -457,8 +457,8 @@ void PrintJobRecovery::resume() {
#if HAS_LEVELING
// Restore leveling state before 'G92 Z' to ensure
// the Z stepper count corresponds to the native Z.
if (info.fade || info.leveling) {
sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.leveling), dtostrf(info.fade, 1, 1, str_1));
if (info.fade || info.flag.leveling) {
sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.flag.leveling), dtostrf(info.fade, 1, 1, str_1));
gcode.process_subcommands_now(cmd);
}
#endif
@ -507,15 +507,15 @@ void PrintJobRecovery::resume() {
sprintf_P(cmd, PSTR("G92.9 E%s"), dtostrf(info.current_position.e, 1, 3, str_1));
gcode.process_subcommands_now(cmd);
// Relative axis modes
gcode.axis_relative = info.axis_relative;
TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
LOOP_XYZ(i) update_workspace_offset((AxisEnum)i);
#endif
// Relative axis modes
gcode.axis_relative = info.axis_relative;
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
const uint8_t old_flags = marlin_debug_flags;
marlin_debug_flags |= MARLIN_DEBUG_ECHO;
@ -598,7 +598,7 @@ void PrintJobRecovery::resume() {
#endif
#if HAS_LEVELING
DEBUG_ECHOLNPAIR("leveling: ", int(info.leveling), " fade: ", info.fade);
DEBUG_ECHOLNPAIR("leveling: ", int(info.flag.leveling), " fade: ", info.fade);
#endif
#if ENABLED(FWRETRACT)
DEBUG_ECHOPGM("retract: ");

45
Marlin/src/feature/powerloss.h

@ -47,42 +47,24 @@ typedef struct {
// Machine state
xyze_pos_t current_position;
uint16_t feedrate;
float zraise;
#if HAS_HOME_OFFSET
xyz_pos_t home_offset;
#endif
#if HAS_POSITION_SHIFT
xyz_pos_t position_shift;
#endif
uint16_t feedrate;
#if HAS_MULTI_EXTRUDER
uint8_t active_extruder;
#endif
TERN_(HAS_HOME_OFFSET, xyz_pos_t home_offset);
TERN_(HAS_POSITION_SHIFT, xyz_pos_t position_shift);
TERN_(HAS_MULTI_EXTRUDER, uint8_t active_extruder);
#if DISABLED(NO_VOLUMETRICS)
bool volumetric_enabled;
float filament_size[EXTRUDERS];
#endif
#if HAS_HOTEND
int16_t target_temperature[HOTENDS];
#endif
TERN_(HAS_HOTEND, int16_t target_temperature[HOTENDS]);
TERN_(HAS_HEATED_BED, int16_t target_temperature_bed);
TERN_(HAS_FAN, uint8_t fan_speed[FAN_COUNT]);
#if HAS_HEATED_BED
int16_t target_temperature_bed;
#endif
#if HAS_FAN
uint8_t fan_speed[FAN_COUNT];
#endif
#if HAS_LEVELING
bool leveling;
float fade;
#endif
TERN_(HAS_LEVELING, float fade);
#if ENABLED(FWRETRACT)
float retract[EXTRUDERS], retract_hop;
@ -92,14 +74,9 @@ typedef struct {
#if ENABLED(MIXING_EXTRUDER)
//uint_fast8_t selected_vtool;
//mixer_comp_t color[NR_MIXING_VIRTUAL_TOOLS][MIXING_STEPPERS];
#if ENABLED(GRADIENT_MIX)
gradient_t gradient;
#endif
TERN_(GRADIENT_MIX, gradient_t gradient);
#endif
// Relative axis modes
uint8_t axis_relative;
// SD Filename and position
char sd_filename[MAXPATHNAMELENGTH];
volatile uint32_t sdpos;
@ -107,10 +84,14 @@ typedef struct {
// Job elapsed time
millis_t print_job_elapsed;
// Relative axis modes
uint8_t axis_relative;
// Misc. Marlin flags
struct {
bool dryrun:1; // M111 S8
bool allow_cold_extrusion:1; // M302 P1
TERN_(HAS_LEVELING, bool leveling:1);
} flag;
uint8_t valid_foot;

Loading…
Cancel
Save