Creality3D Power-Loss Recovery
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user