|
@@ -310,6 +310,8 @@ bool no_response = false;
|
|
uint8_t important_status;
|
|
uint8_t important_status;
|
|
uint8_t saved_filament_type;
|
|
uint8_t saved_filament_type;
|
|
|
|
|
|
|
|
+#define SAVED_TARGET_UNSET (X_MIN_POS-1)
|
|
|
|
+float saved_target[NUM_AXIS] = {SAVED_TARGET_UNSET, 0, 0, 0};
|
|
|
|
|
|
// save/restore printing in case that mmu was not responding
|
|
// save/restore printing in case that mmu was not responding
|
|
bool mmu_print_saved = false;
|
|
bool mmu_print_saved = false;
|
|
@@ -330,7 +332,15 @@ float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
|
|
|
|
// For tracing an arc
|
|
// For tracing an arc
|
|
static float offset[3] = {0.0, 0.0, 0.0};
|
|
static float offset[3] = {0.0, 0.0, 0.0};
|
|
-static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
|
|
|
|
+
|
|
|
|
+// Current feedrate
|
|
|
|
+float feedrate = 1500.0;
|
|
|
|
+
|
|
|
|
+// Feedrate for the next move
|
|
|
|
+static float next_feedrate;
|
|
|
|
+
|
|
|
|
+// Original feedrate saved during homing moves
|
|
|
|
+static float saved_feedrate;
|
|
|
|
|
|
// Determines Absolute or Relative Coordinates.
|
|
// Determines Absolute or Relative Coordinates.
|
|
// Also there is bool axis_relative_modes[] per axis flag.
|
|
// Also there is bool axis_relative_modes[] per axis flag.
|
|
@@ -374,8 +384,8 @@ 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
|
|
static 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] = { 0, 0, 0, 0 };
|
|
static float saved_pos[4] = { 0, 0, 0, 0 };
|
|
-//! Feedrate hopefully derived from an active block of the planner at the time the print has been canceled, in mm/min.
|
|
|
|
-static float saved_feedrate2 = 0;
|
|
|
|
|
|
+static uint16_t saved_feedrate2 = 0; //!< Default feedrate (truncated from float)
|
|
|
|
+static int saved_feedmultiply2 = 0;
|
|
static uint8_t saved_active_extruder = 0;
|
|
static uint8_t saved_active_extruder = 0;
|
|
static float saved_extruder_temperature = 0.0; //!< Active extruder temperature
|
|
static float saved_extruder_temperature = 0.0; //!< Active extruder temperature
|
|
static bool saved_extruder_under_pressure = false;
|
|
static bool saved_extruder_under_pressure = false;
|
|
@@ -3658,7 +3668,7 @@ void process_commands()
|
|
|
|
|
|
Set of internal PRUSA commands
|
|
Set of internal PRUSA commands
|
|
|
|
|
|
- PRUSA [ Ping | PRN | FAN | fn | thx | uvlo | fsensor_recover | MMURES | RESET | fv | M28 | SN | Fir | Rev | Lang | Lz | Beat | FR ]
|
|
|
|
|
|
+ PRUSA [ Ping | PRN | FAN | fn | thx | uvlo | MMURES | RESET | fv | M28 | SN | Fir | Rev | Lang | Lz | Beat | FR ]
|
|
|
|
|
|
- `Ping`
|
|
- `Ping`
|
|
- `PRN` - Prints revision of the printer
|
|
- `PRN` - Prints revision of the printer
|
|
@@ -3666,7 +3676,6 @@ void process_commands()
|
|
- `fn` - Prints farm no.
|
|
- `fn` - Prints farm no.
|
|
- `thx`
|
|
- `thx`
|
|
- `uvlo`
|
|
- `uvlo`
|
|
- - `fsensor_recover` - Filament sensor recover - restore print and continue
|
|
|
|
- `MMURES` - Reset MMU
|
|
- `MMURES` - Reset MMU
|
|
- `RESET` - (Careful!)
|
|
- `RESET` - (Careful!)
|
|
- `fv` - ?
|
|
- `fv` - ?
|
|
@@ -3716,12 +3725,6 @@ void process_commands()
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO,0);
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO,0);
|
|
enquecommand_P(PSTR("M24"));
|
|
enquecommand_P(PSTR("M24"));
|
|
}
|
|
}
|
|
-#ifdef FILAMENT_SENSOR
|
|
|
|
- else if (code_seen("fsensor_recover")) // PRUSA fsensor_recover
|
|
|
|
- {
|
|
|
|
- fsensor_restore_print_and_continue();
|
|
|
|
- }
|
|
|
|
-#endif //FILAMENT_SENSOR
|
|
|
|
else if (code_seen("MMURES")) // PRUSA MMURES
|
|
else if (code_seen("MMURES")) // PRUSA MMURES
|
|
{
|
|
{
|
|
mmu_reset();
|
|
mmu_reset();
|
|
@@ -4046,8 +4049,19 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+ get_coordinates(); // For X Y Z E F
|
|
|
|
+
|
|
|
|
+ // When recovering from a previous print move, restore the originally
|
|
|
|
+ // calculated target position on the first USB/SD command. This accounts
|
|
|
|
+ // properly for relative moves
|
|
|
|
+ if ((saved_target[0] != SAVED_TARGET_UNSET) &&
|
|
|
|
+ ((CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_SDCARD) ||
|
|
|
|
+ (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR)))
|
|
|
|
+ {
|
|
|
|
+ memcpy(destination, saved_target, sizeof(destination));
|
|
|
|
+ saved_target[0] = SAVED_TARGET_UNSET;
|
|
|
|
+ }
|
|
|
|
|
|
- get_coordinates(); // For X Y Z E F
|
|
|
|
if (total_filament_used > ((current_position[E_AXIS] - destination[E_AXIS]) * 100)) { //protection against total_filament_used overflow
|
|
if (total_filament_used > ((current_position[E_AXIS] - destination[E_AXIS]) * 100)) { //protection against total_filament_used overflow
|
|
total_filament_used = total_filament_used + ((destination[E_AXIS] - current_position[E_AXIS]) * 100);
|
|
total_filament_used = total_filament_used + ((destination[E_AXIS] - current_position[E_AXIS]) * 100);
|
|
}
|
|
}
|
|
@@ -5366,21 +5380,19 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
|
|
card.openFile(strchr_pointer + 4,true);
|
|
card.openFile(strchr_pointer + 4,true);
|
|
break;
|
|
break;
|
|
|
|
|
|
- //! ### M24 - Start SD print
|
|
|
|
|
|
+ //! ### M24 - Start/resume SD print
|
|
// ----------------------------------
|
|
// ----------------------------------
|
|
case 24:
|
|
case 24:
|
|
- if (!card.paused)
|
|
|
|
- failstats_reset_print();
|
|
|
|
- card.startFileprint();
|
|
|
|
- starttime=_millis();
|
|
|
|
|
|
+ if (isPrintPaused)
|
|
|
|
+ lcd_resume_print();
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ failstats_reset_print();
|
|
|
|
+ card.startFileprint();
|
|
|
|
+ starttime=_millis();
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
|
|
|
|
- //! ### M25 - Pause SD print
|
|
|
|
- // ----------------------------------
|
|
|
|
- case 25:
|
|
|
|
- card.pauseSDPrint();
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
//! ### M26 S\<index\> - Set SD index
|
|
//! ### M26 S\<index\> - Set SD index
|
|
//! Set position in SD card file to index in bytes.
|
|
//! Set position in SD card file to index in bytes.
|
|
//! This command is expected to be called after M23 and before M24.
|
|
//! This command is expected to be called after M23 and before M24.
|
|
@@ -5935,7 +5947,7 @@ Sigma_Exit:
|
|
//! ### M112 - Emergency stop
|
|
//! ### M112 - Emergency stop
|
|
// -----------------------------------------
|
|
// -----------------------------------------
|
|
case 112:
|
|
case 112:
|
|
- kill(_n(""), 3);
|
|
|
|
|
|
+ kill(MSG_M112_KILL, 3);
|
|
break;
|
|
break;
|
|
|
|
|
|
//! ### M140 - Set bed temperature
|
|
//! ### M140 - Set bed temperature
|
|
@@ -7235,19 +7247,27 @@ Sigma_Exit:
|
|
break;
|
|
break;
|
|
#endif //FILAMENTCHANGEENABLE
|
|
#endif //FILAMENTCHANGEENABLE
|
|
|
|
|
|
|
|
+ //! ### M25 - Pause SD print
|
|
//! ### M601 - Pause print
|
|
//! ### M601 - Pause print
|
|
|
|
+ //! ### M125 - Pause print (TODO: not implemented)
|
|
// -------------------------------
|
|
// -------------------------------
|
|
|
|
+ case 25:
|
|
case 601:
|
|
case 601:
|
|
{
|
|
{
|
|
- cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore
|
|
|
|
- lcd_pause_print();
|
|
|
|
|
|
+ if (!isPrintPaused)
|
|
|
|
+ {
|
|
|
|
+ st_synchronize();
|
|
|
|
+ cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore
|
|
|
|
+ lcd_pause_print();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
|
|
//! ### M602 - Resume print
|
|
//! ### M602 - Resume print
|
|
// -------------------------------
|
|
// -------------------------------
|
|
case 602: {
|
|
case 602: {
|
|
- lcd_resume_print();
|
|
|
|
|
|
+ if (isPrintPaused)
|
|
|
|
+ lcd_resume_print();
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -8342,38 +8362,43 @@ void clamp_to_software_endstops(float target[3])
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef MESH_BED_LEVELING
|
|
#ifdef MESH_BED_LEVELING
|
|
- void mesh_plan_buffer_line(const float &x, const float &y, const float &z, const float &e, const float &feed_rate, const uint8_t extruder) {
|
|
|
|
|
|
+void mesh_plan_buffer_line(const float &x, const float &y, const float &z, const float &e, const float &feed_rate, const uint8_t extruder) {
|
|
float dx = x - current_position[X_AXIS];
|
|
float dx = x - current_position[X_AXIS];
|
|
float dy = y - current_position[Y_AXIS];
|
|
float dy = y - current_position[Y_AXIS];
|
|
- float dz = z - current_position[Z_AXIS];
|
|
|
|
int n_segments = 0;
|
|
int n_segments = 0;
|
|
-
|
|
|
|
|
|
+
|
|
if (mbl.active) {
|
|
if (mbl.active) {
|
|
float len = abs(dx) + abs(dy);
|
|
float len = abs(dx) + abs(dy);
|
|
if (len > 0)
|
|
if (len > 0)
|
|
// Split to 3cm segments or shorter.
|
|
// Split to 3cm segments or shorter.
|
|
n_segments = int(ceil(len / 30.f));
|
|
n_segments = int(ceil(len / 30.f));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (n_segments > 1) {
|
|
if (n_segments > 1) {
|
|
|
|
+ // In a multi-segment move explicitly set the final target in the plan
|
|
|
|
+ // as the move will be recalculated in it's entirety
|
|
|
|
+ float gcode_target[NUM_AXIS];
|
|
|
|
+ gcode_target[X_AXIS] = x;
|
|
|
|
+ gcode_target[Y_AXIS] = y;
|
|
|
|
+ gcode_target[Z_AXIS] = z;
|
|
|
|
+ gcode_target[E_AXIS] = e;
|
|
|
|
+
|
|
|
|
+ float dz = z - current_position[Z_AXIS];
|
|
float de = e - current_position[E_AXIS];
|
|
float de = e - current_position[E_AXIS];
|
|
|
|
+
|
|
for (int i = 1; i < n_segments; ++ i) {
|
|
for (int i = 1; i < n_segments; ++ i) {
|
|
float t = float(i) / float(n_segments);
|
|
float t = float(i) / float(n_segments);
|
|
- if (saved_printing || (mbl.active == false)) return;
|
|
|
|
- plan_buffer_line(
|
|
|
|
- current_position[X_AXIS] + t * dx,
|
|
|
|
|
|
+ plan_buffer_line(current_position[X_AXIS] + t * dx,
|
|
current_position[Y_AXIS] + t * dy,
|
|
current_position[Y_AXIS] + t * dy,
|
|
current_position[Z_AXIS] + t * dz,
|
|
current_position[Z_AXIS] + t * dz,
|
|
current_position[E_AXIS] + t * de,
|
|
current_position[E_AXIS] + t * de,
|
|
- feed_rate, extruder);
|
|
|
|
|
|
+ feed_rate, extruder, gcode_target);
|
|
|
|
+ if (waiting_inside_plan_buffer_line_print_aborted)
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// The rest of the path.
|
|
// The rest of the path.
|
|
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
|
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
|
- current_position[X_AXIS] = x;
|
|
|
|
- current_position[Y_AXIS] = y;
|
|
|
|
- current_position[Z_AXIS] = z;
|
|
|
|
- current_position[E_AXIS] = e;
|
|
|
|
}
|
|
}
|
|
#endif // MESH_BED_LEVELING
|
|
#endif // MESH_BED_LEVELING
|
|
|
|
|
|
@@ -8394,9 +8419,7 @@ void prepare_move()
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
- for(int8_t i=0; i < NUM_AXIS; i++) {
|
|
|
|
- current_position[i] = destination[i];
|
|
|
|
- }
|
|
|
|
|
|
+ set_current_to_destination();
|
|
}
|
|
}
|
|
|
|
|
|
void prepare_arc_move(char isclockwise) {
|
|
void prepare_arc_move(char isclockwise) {
|
|
@@ -8604,7 +8627,7 @@ if(0)
|
|
|
|
|
|
if( (_millis() - previous_millis_cmd) > max_inactive_time )
|
|
if( (_millis() - previous_millis_cmd) > max_inactive_time )
|
|
if(max_inactive_time)
|
|
if(max_inactive_time)
|
|
- kill(_n(""), 4);
|
|
|
|
|
|
+ kill(_n("Inactivity Shutdown"), 4);
|
|
if(stepper_inactive_time) {
|
|
if(stepper_inactive_time) {
|
|
if( (_millis() - previous_millis_cmd) > stepper_inactive_time )
|
|
if( (_millis() - previous_millis_cmd) > stepper_inactive_time )
|
|
{
|
|
{
|
|
@@ -8645,7 +8668,7 @@ if(0)
|
|
// ----------------------------------------------------------------
|
|
// ----------------------------------------------------------------
|
|
if ( killCount >= KILL_DELAY)
|
|
if ( killCount >= KILL_DELAY)
|
|
{
|
|
{
|
|
- kill("", 5);
|
|
|
|
|
|
+ kill(NULL, 5);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -8723,6 +8746,16 @@ void kill(const char *full_screen_message, unsigned char id)
|
|
} // Wait for reset
|
|
} // Wait for reset
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Stop: Emergency stop used by overtemp functions which allows recovery
|
|
|
|
+//
|
|
|
|
+// In addition to stopping the print, this prevents subsequent G[0-3] commands to be
|
|
|
|
+// processed via USB (using "Stopped") until the print is resumed via M999 or
|
|
|
|
+// manually started from scratch with the LCD.
|
|
|
|
+//
|
|
|
|
+// Note that the current instruction is completely discarded, so resuming from Stop()
|
|
|
|
+// will introduce either over/under extrusion on the current segment, and will not
|
|
|
|
+// survive a power panic. Switching Stop() to use the pause machinery instead (with
|
|
|
|
+// the addition of disabling the headers) could allow true recovery in the future.
|
|
void Stop()
|
|
void Stop()
|
|
{
|
|
{
|
|
disable_heater();
|
|
disable_heater();
|
|
@@ -9117,10 +9150,8 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi
|
|
destination[X_AXIS] = ix * (x_dimension / (x_points_num - 1)) + shift_x;
|
|
destination[X_AXIS] = ix * (x_dimension / (x_points_num - 1)) + shift_x;
|
|
destination[Y_AXIS] = iy * (y_dimension / (y_points_num - 1)) + shift_y;
|
|
destination[Y_AXIS] = iy * (y_dimension / (y_points_num - 1)) + shift_y;
|
|
|
|
|
|
- mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], XY_AXIS_FEEDRATE/6, active_extruder);
|
|
|
|
- for(int8_t i=0; i < NUM_AXIS; i++) {
|
|
|
|
- current_position[i] = destination[i];
|
|
|
|
- }
|
|
|
|
|
|
+ mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], XY_AXIS_FEEDRATE/6, active_extruder);
|
|
|
|
+ set_current_to_destination();
|
|
st_synchronize();
|
|
st_synchronize();
|
|
|
|
|
|
// printf_P(PSTR("X = %f; Y= %f \n"), current_position[X_AXIS], current_position[Y_AXIS]);
|
|
// printf_P(PSTR("X = %f; Y= %f \n"), current_position[X_AXIS], current_position[Y_AXIS]);
|
|
@@ -9535,9 +9566,11 @@ float temp_compensation_pinda_thermistor_offset(float temperature_pinda)
|
|
void long_pause() //long pause print
|
|
void long_pause() //long pause print
|
|
{
|
|
{
|
|
st_synchronize();
|
|
st_synchronize();
|
|
-
|
|
|
|
start_pause_print = _millis();
|
|
start_pause_print = _millis();
|
|
|
|
|
|
|
|
+ // Stop heaters
|
|
|
|
+ setAllTargetHotends(0);
|
|
|
|
+
|
|
//retract
|
|
//retract
|
|
current_position[E_AXIS] -= default_retraction;
|
|
current_position[E_AXIS] -= default_retraction;
|
|
plan_buffer_line_curposXYZE(400, active_extruder);
|
|
plan_buffer_line_curposXYZE(400, active_extruder);
|
|
@@ -9552,8 +9585,7 @@ void long_pause() //long pause print
|
|
current_position[Y_AXIS] = Y_PAUSE_POS;
|
|
current_position[Y_AXIS] = Y_PAUSE_POS;
|
|
plan_buffer_line_curposXYZE(50, active_extruder);
|
|
plan_buffer_line_curposXYZE(50, active_extruder);
|
|
|
|
|
|
- // Turn off the hotends and print fan
|
|
|
|
- setAllTargetHotends(0);
|
|
|
|
|
|
+ // Turn off the print fan
|
|
fanSpeed = 0;
|
|
fanSpeed = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -9611,8 +9643,18 @@ void uvlo_()
|
|
if (sd_position < 0) sd_position = 0;
|
|
if (sd_position < 0) sd_position = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- // Backup the feedrate in mm/min.
|
|
|
|
- int feedrate_bckp = blocks_queued() ? (block_buffer[block_buffer_tail].nominal_speed * 60.f) : feedrate;
|
|
|
|
|
|
+ // save the global state at planning time
|
|
|
|
+ uint16_t feedrate_bckp;
|
|
|
|
+ if (blocks_queued())
|
|
|
|
+ {
|
|
|
|
+ memcpy(saved_target, current_block->gcode_target, sizeof(saved_target));
|
|
|
|
+ feedrate_bckp = current_block->gcode_feedrate;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ saved_target[0] = SAVED_TARGET_UNSET;
|
|
|
|
+ feedrate_bckp = feedrate;
|
|
|
|
+ }
|
|
|
|
|
|
// After this call, the planner queue is emptied and the current_position is set to a current logical coordinate.
|
|
// After this call, the planner queue is emptied and the current_position is set to a current logical coordinate.
|
|
// The logical coordinate will likely differ from the machine coordinate if the skew calibration and mesh bed leveling
|
|
// The logical coordinate will likely differ from the machine coordinate if the skew calibration and mesh bed leveling
|
|
@@ -9679,7 +9721,8 @@ void uvlo_()
|
|
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]);
|
|
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]);
|
|
eeprom_update_float((float*)EEPROM_UVLO_CURRENT_POSITION_Z , current_position[Z_AXIS]);
|
|
eeprom_update_float((float*)EEPROM_UVLO_CURRENT_POSITION_Z , current_position[Z_AXIS]);
|
|
// Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates)
|
|
// Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates)
|
|
- EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &feedrate_bckp);
|
|
|
|
|
|
+ eeprom_update_word((uint16_t*)EEPROM_UVLO_FEEDRATE, feedrate_bckp);
|
|
|
|
+ EEPROM_save_B(EEPROM_UVLO_FEEDMULTIPLY, &feedmultiply);
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]);
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]);
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed);
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed);
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED, fanSpeed);
|
|
eeprom_update_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED, fanSpeed);
|
|
@@ -9691,6 +9734,11 @@ void uvlo_()
|
|
#endif
|
|
#endif
|
|
#endif
|
|
#endif
|
|
eeprom_update_word((uint16_t*)(EEPROM_EXTRUDEMULTIPLY), (uint16_t)extrudemultiply);
|
|
eeprom_update_word((uint16_t*)(EEPROM_EXTRUDEMULTIPLY), (uint16_t)extrudemultiply);
|
|
|
|
+ // Store the saved target
|
|
|
|
+ eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+0*4), saved_target[X_AXIS]);
|
|
|
|
+ eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+1*4), saved_target[Y_AXIS]);
|
|
|
|
+ eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+2*4), saved_target[Z_AXIS]);
|
|
|
|
+ eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+3*4), saved_target[E_AXIS]);
|
|
|
|
|
|
// Finaly store the "power outage" flag.
|
|
// Finaly store the "power outage" flag.
|
|
if(sd_print) eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1);
|
|
if(sd_print) eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1);
|
|
@@ -9939,10 +9987,17 @@ void recover_machine_state_after_power_panic(bool bTiny)
|
|
#endif
|
|
#endif
|
|
#endif
|
|
#endif
|
|
extrudemultiply = (int)eeprom_read_word((uint16_t*)(EEPROM_EXTRUDEMULTIPLY));
|
|
extrudemultiply = (int)eeprom_read_word((uint16_t*)(EEPROM_EXTRUDEMULTIPLY));
|
|
|
|
+
|
|
|
|
+ // 9) Recover the saved target
|
|
|
|
+ saved_target[X_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+0*4));
|
|
|
|
+ saved_target[Y_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+1*4));
|
|
|
|
+ saved_target[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+2*4));
|
|
|
|
+ saved_target[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+3*4));
|
|
}
|
|
}
|
|
|
|
|
|
void restore_print_from_eeprom() {
|
|
void restore_print_from_eeprom() {
|
|
int feedrate_rec;
|
|
int feedrate_rec;
|
|
|
|
+ int feedmultiply_rec;
|
|
uint8_t fan_speed_rec;
|
|
uint8_t fan_speed_rec;
|
|
char cmd[30];
|
|
char cmd[30];
|
|
char filename[13];
|
|
char filename[13];
|
|
@@ -9950,9 +10005,12 @@ void restore_print_from_eeprom() {
|
|
char dir_name[9];
|
|
char dir_name[9];
|
|
|
|
|
|
fan_speed_rec = eeprom_read_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED);
|
|
fan_speed_rec = eeprom_read_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED);
|
|
- EEPROM_read_B(EEPROM_UVLO_FEEDRATE, &feedrate_rec);
|
|
|
|
|
|
+ feedrate_rec = eeprom_read_word((uint16_t*)EEPROM_UVLO_FEEDRATE);
|
|
|
|
+ EEPROM_read_B(EEPROM_UVLO_FEEDMULTIPLY, &feedmultiply_rec);
|
|
SERIAL_ECHOPGM("Feedrate:");
|
|
SERIAL_ECHOPGM("Feedrate:");
|
|
- MYSERIAL.println(feedrate_rec);
|
|
|
|
|
|
+ MYSERIAL.print(feedrate_rec);
|
|
|
|
+ SERIAL_ECHOPGM(", feedmultiply:");
|
|
|
|
+ MYSERIAL.println(feedmultiply_rec);
|
|
|
|
|
|
depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH);
|
|
depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH);
|
|
|
|
|
|
@@ -9993,9 +10051,11 @@ void restore_print_from_eeprom() {
|
|
enquecommand(cmd);
|
|
enquecommand(cmd);
|
|
// Unretract.
|
|
// Unretract.
|
|
enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480"));
|
|
enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480"));
|
|
- // Set the feedrate saved at the power panic.
|
|
|
|
|
|
+ // Set the feedrates saved at the power panic.
|
|
sprintf_P(cmd, PSTR("G1 F%d"), feedrate_rec);
|
|
sprintf_P(cmd, PSTR("G1 F%d"), feedrate_rec);
|
|
enquecommand(cmd);
|
|
enquecommand(cmd);
|
|
|
|
+ sprintf_P(cmd, PSTR("M220 S%d"), feedmultiply_rec);
|
|
|
|
+ enquecommand(cmd);
|
|
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS))
|
|
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS))
|
|
{
|
|
{
|
|
enquecommand_P(PSTR("M82")); //E axis abslute mode
|
|
enquecommand_P(PSTR("M82")); //E axis abslute mode
|
|
@@ -10147,16 +10207,21 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-#if 0
|
|
|
|
- saved_feedrate2 = feedrate; //save feedrate
|
|
|
|
-#else
|
|
|
|
- // Try to deduce the feedrate from the first block of the planner.
|
|
|
|
- // Speed is in mm/min.
|
|
|
|
- saved_feedrate2 = blocks_queued() ? (block_buffer[block_buffer_tail].nominal_speed * 60.f) : feedrate;
|
|
|
|
-#endif
|
|
|
|
|
|
+ // save the global state at planning time
|
|
|
|
+ if (blocks_queued())
|
|
|
|
+ {
|
|
|
|
+ memcpy(saved_target, current_block->gcode_target, sizeof(saved_target));
|
|
|
|
+ saved_feedrate2 = current_block->gcode_feedrate;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ saved_target[0] = SAVED_TARGET_UNSET;
|
|
|
|
+ saved_feedrate2 = feedrate;
|
|
|
|
+ }
|
|
|
|
|
|
planner_abort_hard(); //abort printing
|
|
planner_abort_hard(); //abort printing
|
|
memcpy(saved_pos, current_position, sizeof(saved_pos));
|
|
memcpy(saved_pos, current_position, sizeof(saved_pos));
|
|
|
|
+ saved_feedmultiply2 = feedmultiply; //save feedmultiply
|
|
saved_active_extruder = active_extruder; //save active_extruder
|
|
saved_active_extruder = active_extruder; //save active_extruder
|
|
saved_extruder_temperature = degTargetHotend(active_extruder);
|
|
saved_extruder_temperature = degTargetHotend(active_extruder);
|
|
|
|
|
|
@@ -10172,7 +10237,9 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
|
|
sei();
|
|
sei();
|
|
if ((z_move != 0) || (e_move != 0)) { // extruder or z move
|
|
if ((z_move != 0) || (e_move != 0)) { // extruder or z move
|
|
#if 1
|
|
#if 1
|
|
- // Rather than calling plan_buffer_line directly, push the move into the command queue,
|
|
|
|
|
|
+ // Rather than calling plan_buffer_line directly, push the move into the command queue so that
|
|
|
|
+ // the caller can continue processing. This is used during powerpanic to save the state as we
|
|
|
|
+ // move away from the print.
|
|
char buf[48];
|
|
char buf[48];
|
|
|
|
|
|
// First unretract (relative extrusion)
|
|
// First unretract (relative extrusion)
|
|
@@ -10201,6 +10268,7 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
|
|
memcpy(current_position, saved_pos, sizeof(saved_pos));
|
|
memcpy(current_position, saved_pos, sizeof(saved_pos));
|
|
memcpy(destination, current_position, sizeof(destination));
|
|
memcpy(destination, current_position, sizeof(destination));
|
|
#endif
|
|
#endif
|
|
|
|
+ waiting_inside_plan_buffer_line_print_aborted = true; //unroll the stack
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -10234,7 +10302,6 @@ void restore_print_from_ram_and_continue(float e_move)
|
|
wait_for_heater(_millis(), saved_active_extruder);
|
|
wait_for_heater(_millis(), saved_active_extruder);
|
|
heating_status = 2;
|
|
heating_status = 2;
|
|
}
|
|
}
|
|
- feedrate = saved_feedrate2; //restore feedrate
|
|
|
|
axis_relative_modes[E_AXIS] = saved_extruder_relative_mode;
|
|
axis_relative_modes[E_AXIS] = saved_extruder_relative_mode;
|
|
float e = saved_pos[E_AXIS] - e_move;
|
|
float e = saved_pos[E_AXIS] - e_move;
|
|
plan_set_e_position(e);
|
|
plan_set_e_position(e);
|
|
@@ -10257,6 +10324,10 @@ void restore_print_from_ram_and_continue(float e_move)
|
|
fans_check_enabled = true;
|
|
fans_check_enabled = true;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+ // restore original feedrate/feedmultiply _after_ restoring the extruder position
|
|
|
|
+ feedrate = saved_feedrate2;
|
|
|
|
+ feedmultiply = saved_feedmultiply2;
|
|
|
|
+
|
|
memcpy(current_position, saved_pos, sizeof(saved_pos));
|
|
memcpy(current_position, saved_pos, sizeof(saved_pos));
|
|
memcpy(destination, current_position, sizeof(destination));
|
|
memcpy(destination, current_position, sizeof(destination));
|
|
if (saved_printing_type == PRINTING_TYPE_SD) { //was sd printing
|
|
if (saved_printing_type == PRINTING_TYPE_SD) { //was sd printing
|
|
@@ -10272,10 +10343,12 @@ void restore_print_from_ram_and_continue(float e_move)
|
|
else {
|
|
else {
|
|
//not sd printing nor usb printing
|
|
//not sd printing nor usb printing
|
|
}
|
|
}
|
|
|
|
+
|
|
SERIAL_PROTOCOLLNRPGM(MSG_OK); //dummy response because of octoprint is waiting for this
|
|
SERIAL_PROTOCOLLNRPGM(MSG_OK); //dummy response because of octoprint is waiting for this
|
|
lcd_setstatuspgm(_T(WELCOME_MSG));
|
|
lcd_setstatuspgm(_T(WELCOME_MSG));
|
|
saved_printing_type = PRINTING_TYPE_NONE;
|
|
saved_printing_type = PRINTING_TYPE_NONE;
|
|
saved_printing = false;
|
|
saved_printing = false;
|
|
|
|
+ waiting_inside_plan_buffer_line_print_aborted = true; //unroll the stack
|
|
}
|
|
}
|
|
|
|
|
|
void print_world_coordinates()
|
|
void print_world_coordinates()
|