power panic: Re-use saving print file state
This also adds the Gcode position into EEPROM for Octoprint/PrusaLink prints. Though the recovery part doesn't support that yet.
This commit is contained in:
parent
2902fcaa71
commit
67403603ed
|
|
@ -297,6 +297,7 @@ extern bool mesh_bed_leveling_flag;
|
||||||
|
|
||||||
// save/restore printing
|
// save/restore printing
|
||||||
extern bool saved_printing;
|
extern bool saved_printing;
|
||||||
|
extern uint32_t saved_sdpos;
|
||||||
extern uint8_t saved_printing_type;
|
extern uint8_t saved_printing_type;
|
||||||
#define PRINTING_TYPE_SD 0
|
#define PRINTING_TYPE_SD 0
|
||||||
#define PRINTING_TYPE_USB 1
|
#define PRINTING_TYPE_USB 1
|
||||||
|
|
@ -384,6 +385,8 @@ extern void print_world_coordinates();
|
||||||
extern void print_physical_coordinates();
|
extern void print_physical_coordinates();
|
||||||
extern void print_mesh_bed_leveling_table();
|
extern void print_mesh_bed_leveling_table();
|
||||||
|
|
||||||
|
void save_print_file_state();
|
||||||
|
void restore_print_file_state();
|
||||||
extern void stop_and_save_print_to_ram(float z_move, float e_move);
|
extern void stop_and_save_print_to_ram(float z_move, float e_move);
|
||||||
void restore_extruder_temperature_from_ram();
|
void restore_extruder_temperature_from_ram();
|
||||||
extern void restore_print_from_ram_and_continue(float e_move);
|
extern void restore_print_from_ram_and_continue(float e_move);
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ static bool chdkActive = false;
|
||||||
//! @name RAM save/restore printing
|
//! @name RAM save/restore printing
|
||||||
//! @{
|
//! @{
|
||||||
bool saved_printing = false; //!< Print is paused and saved in RAM
|
bool saved_printing = false; //!< Print is paused and saved in RAM
|
||||||
static uint32_t saved_sdpos = 0; //!< SD card position, or line number in case of USB printing
|
uint32_t saved_sdpos = 0; //!< SD card position, or line number in case of USB printing
|
||||||
uint8_t saved_printing_type = PRINTING_TYPE_SD;
|
uint8_t saved_printing_type = PRINTING_TYPE_SD;
|
||||||
static float saved_pos[4] = { X_COORD_INVALID, 0, 0, 0 };
|
static float saved_pos[4] = { X_COORD_INVALID, 0, 0, 0 };
|
||||||
static uint16_t saved_feedrate2 = 0; //!< Default feedrate (truncated from float)
|
static uint16_t saved_feedrate2 = 0; //!< Default feedrate (truncated from float)
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,7 @@ void uvlo_() {
|
||||||
setTargetBed(0);
|
setTargetBed(0);
|
||||||
|
|
||||||
// Calculate the file position, from which to resume this print.
|
// Calculate the file position, from which to resume this print.
|
||||||
long sd_position = sdpos_atomic; //atomic sd position of last command added in queue
|
save_print_file_state();
|
||||||
uint16_t sdlen_planner = planner_calc_sd_length(); //length of sd commands in planner
|
|
||||||
sd_position -= sdlen_planner;
|
|
||||||
uint16_t sdlen_cmdqueue = cmdqueue_calc_sd_length(); //length of sd commands in cmdqueue
|
|
||||||
sd_position -= sdlen_cmdqueue;
|
|
||||||
if (sd_position < 0) sd_position = 0;
|
|
||||||
|
|
||||||
// save the global state at planning time
|
// save the global state at planning time
|
||||||
bool pos_invalid = mesh_bed_leveling_flag || homing_flag;
|
bool pos_invalid = mesh_bed_leveling_flag || homing_flag;
|
||||||
|
|
@ -134,7 +129,7 @@ void uvlo_() {
|
||||||
poweroff_z();
|
poweroff_z();
|
||||||
|
|
||||||
// Write the file position.
|
// Write the file position.
|
||||||
eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position);
|
eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), saved_sdpos);
|
||||||
|
|
||||||
// Store the mesh bed leveling offsets. This is 2*7*7=98 bytes, which takes 98*3.4us=333us in worst case.
|
// Store the mesh bed leveling offsets. This is 2*7*7=98 bytes, which takes 98*3.4us=333us in worst case.
|
||||||
for (uint8_t mesh_point = 0; mesh_point < MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS; ++ mesh_point)
|
for (uint8_t mesh_point = 0; mesh_point < MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS; ++ mesh_point)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue