diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde
index 34d50e3c46c9e28cb0cc93b2de0b9fac5cf5650e..c0fc8675c18803314ccedde5bc667d62f86fc2fd 100644
--- a/Marlin/Marlin.pde
+++ b/Marlin/Marlin.pde
@@ -695,7 +695,17 @@ inline void process_commands()
case 109:
{// M109 - Wait for extruder heater to reach target.
LCD_MESSAGEPGM("Heating...");
+ autotemp_enabled=false;
if (code_seen('S')) setTargetHotend0(code_value());
+ #ifdef AUTOTEMP
+ if (code_seen('S')) autotemp_min=code_value();
+ if (code_seen('T')) autotemp_max=code_value();
+ if (code_seen('F'))
+ {
+ autotemp_factor=code_value();
+ autotemp_enabled=true;
+ }
+ #endif
setWatch();
codenum = millis();
diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp
index c27d58601764752d510a48b5bcf5b74aa5439aa7..0a226c66f79a2dedf8bbe75d85bb58480fea6225 100644
--- a/Marlin/planner.cpp
+++ b/Marlin/planner.cpp
@@ -87,7 +87,10 @@ static float previous_speed[4]; // Speed of previous path line segment
static float previous_nominal_speed; // Nominal speed of previous path line segment
#ifdef AUTOTEMP
-float high_e_speed=0;
+ float autotemp_max=250;
+ float autotemp_min=210;
+ float autotemp_factor=1;
+ bool autotemp_enabled=false;
#endif
@@ -379,26 +382,29 @@ block_t *plan_get_current_block() {
#ifdef AUTOTEMP
void getHighESpeed()
{
- if(degTargetHotend0()+2<AUTOTEMP_MIN) //probably temperature set to zero.
+ if(!autotemp_enabled)
+ return;
+ if(degTargetHotend0()+2<autotemp_min) //probably temperature set to zero.
return; //do nothing
+
float high=0;
char block_index = block_buffer_tail;
while(block_index != block_buffer_head) {
- float se=block_buffer[block_index].speed_e;
+ float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
+ //se; units steps/sec;
if(se>high)
{
high=se;
}
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
}
- high_e_speed=high*axis_steps_per_unit[E_AXIS]/(1000000.0); //so it is independent of the esteps/mm. before
- float g=AUTOTEMP_MIN+high_e_speed*AUTOTEMP_FACTOR;
- float t=constrain(AUTOTEMP_MIN,g,AUTOTEMP_MAX);
+ float g=autotemp_min+high*autotemp_factor;
+ float t=constrain(autotemp_min,g,autotemp_max);
setTargetHotend0(t);
SERIAL_ECHO_START;
- SERIAL_ECHOPAIR("highe",high_e_speed);
+ SERIAL_ECHOPAIR("highe",high);
SERIAL_ECHOPAIR(" t",t);
SERIAL_ECHOLN("");
}
diff --git a/Marlin/planner.h b/Marlin/planner.h
index be1587d6b805acef4431d1d0481f27e7ed5375dd..ec497d50648171974487cef8c20b1c55bdccb9da 100644
--- a/Marlin/planner.h
+++ b/Marlin/planner.h
@@ -92,7 +92,13 @@ extern float max_xy_jerk; //speed than can be stopped at once, if i understand c
extern float max_z_jerk;
extern float mintravelfeedrate;
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
+
+
#ifdef AUTOTEMP
-extern float high_e_speed;
+ extern bool autotemp_enabled;
+ extern float autotemp_max;
+ extern float autotemp_min;
+ extern float autotemp_factor;
#endif
+
#endif