|
@@ -780,7 +780,7 @@ inline void process_commands()
|
780
|
780
|
#ifdef WATCHPERIOD
|
781
|
781
|
if(target_raw[0] > current_raw[0]){
|
782
|
782
|
watchmillis = max(1,millis());
|
783
|
|
- watch_raw[0] = current_raw[0];
|
|
783
|
+ watch_raw = current_raw[0];
|
784
|
784
|
}else{
|
785
|
785
|
watchmillis = 0;
|
786
|
786
|
}
|
|
@@ -820,32 +820,54 @@ inline void process_commands()
|
820
|
820
|
#endif
|
821
|
821
|
return;
|
822
|
822
|
//break;
|
823
|
|
- case 109: // M109 - Wait for extruder heater to reach target.
|
824
|
|
- LCD_MESSAGE("Heating...");
|
825
|
|
- if (code_seen('S')) target_raw[0] = temp2analog(code_value());
|
826
|
|
-#ifdef PIDTEMP
|
827
|
|
- pid_setpoint = code_value();
|
828
|
|
-#endif //PIDTEM
|
829
|
|
- #ifdef WATCHPERIOD
|
830
|
|
- if(target_raw[0]>current_raw[0]){
|
|
823
|
+ case 109: {// M109 - Wait for extruder heater to reach target.
|
|
824
|
+ LCD_MESSAGE("Heating...");
|
|
825
|
+ if (code_seen('S')) target_raw[0] = temp2analog(code_value());
|
|
826
|
+ #ifdef PIDTEMP
|
|
827
|
+ pid_setpoint = code_value();
|
|
828
|
+ #endif //PIDTEM
|
|
829
|
+ #ifdef WATCHPERIOD
|
|
830
|
+ if(target_raw[0]>current_raw[0]) {
|
831
|
831
|
watchmillis = max(1,millis());
|
832
|
|
- watch_raw[0] = current_raw[0];
|
833
|
|
- }else{
|
|
832
|
+ watch_raw = current_raw[0];
|
|
833
|
+ } else {
|
834
|
834
|
watchmillis = 0;
|
835
|
|
- }
|
836
|
|
- #endif
|
837
|
|
- codenum = millis();
|
838
|
|
- starttime=millis();
|
839
|
|
- while(current_raw[0] < target_raw[0]) {
|
840
|
|
- if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up.
|
841
|
|
- Serial.print("T:");
|
842
|
|
- Serial.println( analog2temp(current_raw[0]) );
|
843
|
|
- codenum = millis();
|
844
|
835
|
}
|
845
|
|
- LCD_STATUS;
|
846
|
|
- manage_heater();
|
|
836
|
+ #endif //WATCHPERIOD
|
|
837
|
+ codenum = millis();
|
|
838
|
+
|
|
839
|
+ /* See if we are heating up or cooling down */
|
|
840
|
+ bool target_direction = (current_raw[0] < target_raw[0]); // true if heating, false if cooling
|
|
841
|
+
|
|
842
|
+ #ifdef TEMP_RESIDENCY_TIME
|
|
843
|
+ long residencyStart;
|
|
844
|
+ residencyStart = -1;
|
|
845
|
+ /* continue to loop until we have reached the target temp
|
|
846
|
+ _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
|
847
|
+ while((target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0])) ||
|
|
848
|
+ (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
|
849
|
+ #else
|
|
850
|
+ while ( target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0]) ) {
|
|
851
|
+ #endif //TEMP_RESIDENCY_TIME
|
|
852
|
+ if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down
|
|
853
|
+ Serial.print("T:");
|
|
854
|
+ Serial.println( analog2temp(current_raw[0]) );
|
|
855
|
+ codenum = millis();
|
|
856
|
+ }
|
|
857
|
+ manage_heater();
|
|
858
|
+ LCD_STATUS;
|
|
859
|
+ #ifdef TEMP_RESIDENCY_TIME
|
|
860
|
+ /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
|
|
861
|
+ or when current temp falls outside the hysteresis after target temp was reached */
|
|
862
|
+ if ((residencyStart == -1 && target_direction && current_raw[0] >= target_raw[0]) ||
|
|
863
|
+ (residencyStart == -1 && !target_direction && current_raw[0] <= target_raw[0]) ||
|
|
864
|
+ (residencyStart > -1 && labs(analog2temp(current_raw[0]) - analog2temp(target_raw[0])) > TEMP_HYSTERESIS) ) {
|
|
865
|
+ residencyStart = millis();
|
|
866
|
+ }
|
|
867
|
+ #endif //TEMP_RESIDENCY_TIME
|
|
868
|
+ }
|
|
869
|
+ LCD_MESSAGE("Marlin ready.");
|
847
|
870
|
}
|
848
|
|
- LCD_MESSAGE("UltiMarlin ready.");
|
849
|
871
|
break;
|
850
|
872
|
case 190: // M190 - Wait bed for heater to reach target.
|
851
|
873
|
#if TEMP_1_PIN > -1
|