From c6f694a247783443e2b6ee57e635202bf2e301b3 Mon Sep 17 00:00:00 2001 From: The-Force Date: Thu, 31 Oct 2019 20:09:37 +0100 Subject: [PATCH] Power Loss Recovery for volumetric extrusion (#15734) --- Marlin/src/feature/power_loss_recovery.cpp | 30 ++++++++++++++++++++++ Marlin/src/feature/power_loss_recovery.h | 9 +++++++ 2 files changed, 39 insertions(+) diff --git a/Marlin/src/feature/power_loss_recovery.cpp b/Marlin/src/feature/power_loss_recovery.cpp index c438dffa3..1cea125df 100644 --- a/Marlin/src/feature/power_loss_recovery.cpp +++ b/Marlin/src/feature/power_loss_recovery.cpp @@ -183,6 +183,15 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*= info.active_extruder = active_extruder; #endif + #if DISABLED(NO_VOLUMETRICS) + info.volumetric_enabled = parser.volumetric_enabled; + #if EXTRUDERS > 1 + for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e]; + #else + if (parser.volumetric_enabled) info.filament_size = planner.filament_size[active_extruder]; + #endif + #endif + #if EXTRUDERS HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target; #endif @@ -291,6 +300,27 @@ void PrintJobRecovery::resume() { gcode.process_subcommands_now(cmd); #endif + // Recover volumetric extrusion state + #if DISABLED(NO_VOLUMETRICS) + #if EXTRUDERS > 1 + for (int8_t e = 0; e < EXTRUDERS; e++) { + dtostrf(info.filament_size[e], 1, 3, str_1); + sprintf_P(cmd, PSTR("M200 T%i D%s"), e, str_1); + gcode.process_subcommands_now(cmd); + } + if (!info.volumetric_enabled) { + sprintf_P(cmd, PSTR("M200 T%i D0"), info.active_extruder); + gcode.process_subcommands_now(cmd); + } + #else + if (info.volumetric_enabled) { + dtostrf(info.filament_size, 1, 3, str_1); + sprintf_P(cmd, PSTR("M200 D%s"), str_1); + gcode.process_subcommands_now(cmd); + } + #endif + #endif + #if HAS_HEATED_BED const int16_t bt = info.target_temperature_bed; if (bt) { diff --git a/Marlin/src/feature/power_loss_recovery.h b/Marlin/src/feature/power_loss_recovery.h index 9f947701e..20248a2e4 100644 --- a/Marlin/src/feature/power_loss_recovery.h +++ b/Marlin/src/feature/power_loss_recovery.h @@ -59,6 +59,15 @@ typedef struct { uint8_t active_extruder; #endif + #if DISABLED(NO_VOLUMETRICS) + bool volumetric_enabled; + #if EXTRUDERS > 1 + float filament_size[EXTRUDERS]; + #else + float filament_size; + #endif + #endif + #if HOTENDS int16_t target_temperature[HOTENDS]; #endif