Merge pull request #10479 from thinkyhead/bf2_creality_power_loss_resume
[2.0.x] Creality3D Power-Loss Recovery
This commit is contained in:
@ -152,7 +152,9 @@
|
||||
* None Home to all axes with no parameters.
|
||||
* With QUICK_HOME enabled XY will home together, then Z.
|
||||
*
|
||||
* Cartesian parameters
|
||||
* Rn Raise by n mm/inches before homing
|
||||
*
|
||||
* Cartesian/SCARA parameters
|
||||
*
|
||||
* X Home to the X endstop
|
||||
* Y Home to the Y endstop
|
||||
@ -226,12 +228,13 @@ void GcodeSuite::G28(const bool always_home_all) {
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(UNKNOWN_Z_NO_RAISE)
|
||||
const float z_homing_height = axis_known_position[Z_AXIS] ? Z_HOMING_HEIGHT : 0;
|
||||
#else
|
||||
constexpr float z_homing_height = Z_HOMING_HEIGHT;
|
||||
#endif
|
||||
|
||||
const float z_homing_height = (
|
||||
#if ENABLED(UNKNOWN_Z_NO_RAISE)
|
||||
!axis_known_position[Z_AXIS] ? 0 :
|
||||
#endif
|
||||
(parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT)
|
||||
);
|
||||
|
||||
if (z_homing_height && (home_all || homeX || homeY)) {
|
||||
// Raise Z before homing any other axes and z is not already high enough (never lower z)
|
||||
destination[Z_AXIS] = z_homing_height;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../queue.h"
|
||||
#include "../../libs/hex_print_routines.h"
|
||||
|
||||
#include "../../Marlin.h" // for idle()
|
||||
@ -59,8 +60,6 @@
|
||||
|
||||
#define TEST_BYTE ((char) 0xE5)
|
||||
|
||||
extern char command_queue[BUFSIZE][MAX_CMD_SIZE];
|
||||
|
||||
extern char* __brkval;
|
||||
extern size_t __heap_start, __heap_end, __flp;
|
||||
extern char __bss_end;
|
||||
|
@ -37,6 +37,10 @@
|
||||
#include "../feature/leds/leds.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../feature/power_loss_recovery.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GCode line number handling. Hosts may opt to include line numbers when
|
||||
* sending commands to Marlin, and lines will be checked for sequentiality.
|
||||
@ -115,7 +119,7 @@ inline void _commit_command(bool say_ok
|
||||
* Return true if the command was successfully added.
|
||||
* Return false for a full buffer, or if the 'command' is a comment.
|
||||
*/
|
||||
inline bool _enqueuecommand(const char* cmd, bool say_ok
|
||||
inline bool _enqueuecommand(const char* cmd, bool say_ok=false
|
||||
#if NUM_SERIAL > 1
|
||||
, int16_t port = -1
|
||||
#endif
|
||||
@ -133,8 +137,8 @@ inline bool _enqueuecommand(const char* cmd, bool say_ok
|
||||
/**
|
||||
* Enqueue with Serial Echo
|
||||
*/
|
||||
bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) {
|
||||
if (_enqueuecommand(cmd, say_ok)) {
|
||||
bool enqueue_and_echo_command(const char* cmd) {
|
||||
if (_enqueuecommand(cmd)) {
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPAIR(MSG_ENQUEUEING, cmd);
|
||||
SERIAL_CHAR('"');
|
||||
@ -486,6 +490,22 @@ inline void get_serial_commands() {
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
|
||||
inline bool drain_job_recovery_commands() {
|
||||
static uint8_t job_recovery_commands_index = 0; // Resets on reboot
|
||||
if (job_recovery_commands_count) {
|
||||
if (_enqueuecommand(job_recovery_commands[job_recovery_commands_index])) {
|
||||
++job_recovery_commands_index;
|
||||
if (!--job_recovery_commands_count) job_recovery_phase = JOB_RECOVERY_IDLE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
||||
/**
|
||||
@ -501,6 +521,11 @@ void get_available_commands() {
|
||||
|
||||
get_serial_commands();
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
// Commands for power-loss recovery take precedence
|
||||
if (job_recovery_phase == JOB_RECOVERY_YES && drain_job_recovery_commands()) return;
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
get_sdcard_commands();
|
||||
#endif
|
||||
@ -543,8 +568,12 @@ void advance_command_queue() {
|
||||
ok_to_send();
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
gcode.process_next_command();
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
if (card.cardOK && card.sdprinting) save_job_recovery_info();
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
@ -95,7 +95,7 @@ void enqueue_and_echo_commands_P(const char * const pgcode);
|
||||
/**
|
||||
* Enqueue with Serial Echo
|
||||
*/
|
||||
bool enqueue_and_echo_command(const char* cmd, bool say_ok=false);
|
||||
bool enqueue_and_echo_command(const char* cmd);
|
||||
|
||||
#define HAS_LCD_QUEUE_NOW (ENABLED(MALYAN_LCD) || (ENABLED(ULTIPANEL) && (ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE))))
|
||||
#define HAS_QUEUE_NOW (ENABLED(SDSUPPORT) || HAS_LCD_QUEUE_NOW)
|
||||
|
@ -29,13 +29,16 @@
|
||||
#include "../../module/printcounter.h"
|
||||
#include "../../module/stepper.h"
|
||||
|
||||
#if ENABLED(PARK_HEAD_ON_PAUSE)
|
||||
#include "../../feature/pause.h"
|
||||
#include "../queue.h"
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../feature/power_loss_recovery.h"
|
||||
#endif
|
||||
|
||||
#if NUM_SERIAL > 1
|
||||
#include "../../gcode/queue.h"
|
||||
#if ENABLED(PARK_HEAD_ON_PAUSE)
|
||||
#include "../../feature/pause.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PARK_HEAD_ON_PAUSE) || NUM_SERIAL > 1
|
||||
#include "../queue.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -78,6 +81,10 @@ void GcodeSuite::M23() {
|
||||
* M24: Start or Resume SD Print
|
||||
*/
|
||||
void GcodeSuite::M24() {
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
card.removeJobRecoveryFile();
|
||||
#endif
|
||||
|
||||
#if ENABLED(PARK_HEAD_ON_PAUSE)
|
||||
resume_print();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user