Browse Source

Merge pull request #2003 from mkbel/heat_hysteresis

Heat hysteresis
DRracer 5 years ago
parent
commit
d65b333664
2 changed files with 8 additions and 35 deletions
  1. 8 6
      Firmware/Marlin_main.cpp
  2. 0 29
      Firmware/fsensor.cpp

+ 8 - 6
Firmware/Marlin_main.cpp

@@ -9456,10 +9456,11 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
 
 //! @brief Restore print from ram
 //!
-//! Restore print saved by stop_and_save_print_to_ram(). Is blocking,
-//! waits for extruder temperature restore, then restores position and continues
-//! print moves.
-//! Internaly lcd_update() is called by wait_for_heater().
+//! Restore print saved by stop_and_save_print_to_ram(). Is blocking, restores
+//! print fan speed, waits for extruder temperature restore, then restores
+//! position and continues print moves.
+//!
+//! Internally lcd_update() is called by wait_for_heater().
 //!
 //! @param e_move
 void restore_print_from_ram_and_continue(float e_move)
@@ -9474,7 +9475,9 @@ void restore_print_from_ram_and_continue(float e_move)
 //	for (int axis = X_AXIS; axis <= E_AXIS; axis++)
 //	    current_position[axis] = st_get_position_mm(axis);
 	active_extruder = saved_active_extruder; //restore active_extruder
-	if (saved_extruder_temperature) {
+	fanSpeed = saved_fanSpeed;
+	if (degTargetHotend(saved_active_extruder) != saved_extruder_temperature)
+	{
 		setTargetHotendSafe(saved_extruder_temperature, saved_active_extruder);
 		heating_status = 1;
 		wait_for_heater(_millis(), saved_active_extruder);
@@ -9482,7 +9485,6 @@ void restore_print_from_ram_and_continue(float e_move)
 	}
 	feedrate = saved_feedrate2; //restore feedrate
 	axis_relative_modes[E_AXIS] = saved_extruder_relative_mode;
-	fanSpeed = saved_fanSpeed;
 	float e = saved_pos[E_AXIS] - e_move;
 	plan_set_e_position(e);
   

+ 0 - 29
Firmware/fsensor.cpp

@@ -522,19 +522,6 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
 	}
 }
 
-//! This ensures generating z-position at least 25mm above the heat bed.
-//! Making this a template enables changing the computation data type easily at all spots where necessary.
-//! @param current_z current z-position
-//! @return z-position at least 25mm above the heat bed plus FILAMENTCHANGE_ZADD 
-template <typename T>
-inline T fsensor_clamp_z(float current_z){
-	T z( current_z );
-	if(z < T(25)){ // make sure the compiler understands, that the constant 25 is of correct type
-		// - necessary for uint8_t -> results in shorter code
-		z = T(25); // move to at least 25mm above heat bed
-	}
-	return z + T(FILAMENTCHANGE_ZADD); // always move above the printout by FILAMENTCHANGE_ZADD (default 2mm)	
-}
 
 //! Common code for enqueing M600 and supplemental codes into the command queue.
 //! Used both for the IR sensor and the PAT9125
@@ -545,22 +532,6 @@ void fsensor_enque_M600(){
 	enquecommand_front_P(PSTR("PRUSA fsensor_recover"));
 	fsensor_m600_enqueued = true;
 	enquecommand_front_P((PSTR("M600")));
-#define xstr(a) str(a)
-#define str(a) #a
-	static const char gcodeMove[] PROGMEM = 
-			"G1 X" xstr(FILAMENTCHANGE_XPOS) 
-			" Y" xstr(FILAMENTCHANGE_YPOS) 
-			" Z%u";
-#undef str
-#undef xstr
-	char buf[32];
-	// integer arithmetics is far shorter, I don't need a precise float position here, just move a bit above
-	// 8bit arithmetics in fsensor_clamp_z is 10B shorter than 16bit (not talking about float ;) ) 
-	// The compile-time static_assert here ensures, that the computation gets enough bits in case of Z-range too high,
-	// i.e. makes the user change the data type, which also results in larger code
-	static_assert(Z_MAX_POS < (255 - FILAMENTCHANGE_ZADD), "Z-range too high, change fsensor_clamp_z<uint8_t> to <uint16_t>");
-	sprintf_P(buf, gcodeMove, fsensor_clamp_z<uint8_t>(current_position[Z_AXIS]) );
-	enquecommand_front(buf, false);
 }
 
 //! @brief filament sensor update (perform M600 on filament runout)