|
@@ -174,7 +174,7 @@ static unsigned long stepper_inactive_time = 0;
|
174
|
174
|
static unsigned long starttime=0;
|
175
|
175
|
static unsigned long stoptime=0;
|
176
|
176
|
|
177
|
|
-
|
|
177
|
+static uint8_t tmp_extruder;
|
178
|
178
|
|
179
|
179
|
//===========================================================================
|
180
|
180
|
//=============================ROUTINES=============================
|
|
@@ -641,7 +641,6 @@ inline void process_commands()
|
641
|
641
|
//processed in write to file routine above
|
642
|
642
|
//card,saving = false;
|
643
|
643
|
break;
|
644
|
|
-
|
645
|
644
|
#endif //SDSUPPORT
|
646
|
645
|
|
647
|
646
|
case 30: //M30 take time since the start of the SD print or an M109 command
|
|
@@ -684,19 +683,36 @@ inline void process_commands()
|
684
|
683
|
}
|
685
|
684
|
break;
|
686
|
685
|
case 104: // M104
|
687
|
|
- if (code_seen('S')) setTargetHotend0(code_value());
|
|
686
|
+ tmp_extruder = active_extruder;
|
|
687
|
+ if(code_seen('T')) {
|
|
688
|
+ tmp_extruder = code_value();
|
|
689
|
+ if(tmp_extruder >= EXTRUDERS) {
|
|
690
|
+ SERIAL_ECHO_START;
|
|
691
|
+ SERIAL_ECHO("M104 Invalid extruder ");
|
|
692
|
+ SERIAL_ECHOLN(tmp_extruder);
|
|
693
|
+ break;
|
|
694
|
+ }
|
|
695
|
+ }
|
|
696
|
+ if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
|
688
|
697
|
setWatch();
|
689
|
698
|
break;
|
690
|
699
|
case 140: // M140 set bed temp
|
691
|
700
|
if (code_seen('S')) setTargetBed(code_value());
|
692
|
701
|
break;
|
693
|
702
|
case 105 : // M105
|
694
|
|
- //SERIAL_ECHOLN(freeMemory());
|
695
|
|
- //test watchdog:
|
696
|
|
- //delay(20000);
|
697
|
|
- #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
|
703
|
+ tmp_extruder = active_extruder;
|
|
704
|
+ if(code_seen('T')) {
|
|
705
|
+ tmp_extruder = code_value();
|
|
706
|
+ if(tmp_extruder >= EXTRUDERS) {
|
|
707
|
+ SERIAL_ECHO_START;
|
|
708
|
+ SERIAL_ECHO("M105 Invalid extruder ");
|
|
709
|
+ SERIAL_ECHOLN(tmp_extruder);
|
|
710
|
+ break;
|
|
711
|
+ }
|
|
712
|
+ }
|
|
713
|
+ #if (TEMP_0_PIN > -1) || (TEMP_2_PIN > -1)
|
698
|
714
|
SERIAL_PROTOCOLPGM("ok T:");
|
699
|
|
- SERIAL_PROTOCOL( degHotend0());
|
|
715
|
+ SERIAL_PROTOCOL( degHotend(tmp_extruder));
|
700
|
716
|
#if TEMP_1_PIN > -1
|
701
|
717
|
SERIAL_PROTOCOLPGM(" B:");
|
702
|
718
|
SERIAL_PROTOCOL(degBed());
|
|
@@ -715,41 +731,51 @@ inline void process_commands()
|
715
|
731
|
break;
|
716
|
732
|
case 109:
|
717
|
733
|
{// M109 - Wait for extruder heater to reach target.
|
718
|
|
- LCD_MESSAGEPGM("Heating...");
|
719
|
|
- #ifdef AUTOTEMP
|
720
|
|
- autotemp_enabled=false;
|
721
|
|
- #endif
|
722
|
|
- if (code_seen('S')) setTargetHotend0(code_value());
|
723
|
|
- #ifdef AUTOTEMP
|
724
|
|
- if (code_seen('S')) autotemp_min=code_value();
|
725
|
|
- if (code_seen('T')) autotemp_max=code_value();
|
726
|
|
- if (code_seen('F'))
|
727
|
|
- {
|
728
|
|
- autotemp_factor=code_value();
|
729
|
|
- autotemp_enabled=true;
|
730
|
|
- }
|
731
|
|
- #endif
|
732
|
|
-
|
733
|
|
- setWatch();
|
734
|
|
- codenum = millis();
|
735
|
|
-
|
736
|
|
- /* See if we are heating up or cooling down */
|
737
|
|
- bool target_direction = isHeatingHotend0(); // true if heating, false if cooling
|
738
|
|
-
|
739
|
|
- #ifdef TEMP_RESIDENCY_TIME
|
740
|
|
- long residencyStart;
|
741
|
|
- residencyStart = -1;
|
742
|
|
- /* continue to loop until we have reached the target temp
|
743
|
|
- _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
744
|
|
- while((target_direction ? (isHeatingHotend0()) : (isCoolingHotend0())) ||
|
745
|
|
- (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
746
|
|
- #else
|
747
|
|
- while ( target_direction ? (isHeatingHotend0()) : (isCoolingHotend0()&&(CooldownNoWait==false)) ) {
|
748
|
|
- #endif //TEMP_RESIDENCY_TIME
|
|
734
|
+ tmp_extruder = active_extruder;
|
|
735
|
+ if(code_seen('T')) {
|
|
736
|
+ tmp_extruder = code_value();
|
|
737
|
+ if(tmp_extruder >= EXTRUDERS) {
|
|
738
|
+ SERIAL_ECHO_START;
|
|
739
|
+ SERIAL_ECHO("M109 Invalid extruder ");
|
|
740
|
+ SERIAL_ECHOLN(tmp_extruder);
|
|
741
|
+ break;
|
|
742
|
+ }
|
|
743
|
+ }
|
|
744
|
+ LCD_MESSAGEPGM("Heating...");
|
|
745
|
+ #ifdef AUTOTEMP
|
|
746
|
+ autotemp_enabled=false;
|
|
747
|
+ #endif
|
|
748
|
+ if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
|
|
749
|
+ #ifdef AUTOTEMP
|
|
750
|
+ if (code_seen('S')) autotemp_min=code_value();
|
|
751
|
+ if (code_seen('G')) autotemp_max=code_value();
|
|
752
|
+ if (code_seen('F'))
|
|
753
|
+ {
|
|
754
|
+ autotemp_factor=code_value();
|
|
755
|
+ autotemp_enabled=true;
|
|
756
|
+ }
|
|
757
|
+ #endif
|
|
758
|
+
|
|
759
|
+ setWatch();
|
|
760
|
+ codenum = millis();
|
|
761
|
+
|
|
762
|
+ /* See if we are heating up or cooling down */
|
|
763
|
+ bool target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
|
|
764
|
+
|
|
765
|
+ #ifdef TEMP_RESIDENCY_TIME
|
|
766
|
+ long residencyStart;
|
|
767
|
+ residencyStart = -1;
|
|
768
|
+ /* continue to loop until we have reached the target temp
|
|
769
|
+ _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
|
770
|
+ while((target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder))) ||
|
|
771
|
+ (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
|
772
|
+ #else
|
|
773
|
+ while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
|
|
774
|
+ #endif //TEMP_RESIDENCY_TIME
|
749
|
775
|
if( (millis() - codenum) > 1000 )
|
750
|
776
|
{ //Print Temp Reading every 1 second while heating up/cooling down
|
751
|
777
|
SERIAL_PROTOCOLPGM("T:");
|
752
|
|
- SERIAL_PROTOCOLLN( degHotend0() );
|
|
778
|
+ SERIAL_PROTOCOLLN( degHotend(tmp_extruder) );
|
753
|
779
|
codenum = millis();
|
754
|
780
|
}
|
755
|
781
|
manage_heater();
|
|
@@ -757,9 +783,9 @@ inline void process_commands()
|
757
|
783
|
#ifdef TEMP_RESIDENCY_TIME
|
758
|
784
|
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
|
759
|
785
|
or when current temp falls outside the hysteresis after target temp was reached */
|
760
|
|
- if ((residencyStart == -1 && target_direction && !isHeatingHotend0()) ||
|
761
|
|
- (residencyStart == -1 && !target_direction && !isCoolingHotend0()) ||
|
762
|
|
- (residencyStart > -1 && labs(degHotend0() - degTargetHotend0()) > TEMP_HYSTERESIS) )
|
|
786
|
+ if ((residencyStart == -1 && target_direction && !isHeatingHotend(tmp_extruder)) ||
|
|
787
|
+ (residencyStart == -1 && !target_direction && !isCoolingHotend(tmp_extruder)) ||
|
|
788
|
+ (residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
|
763
|
789
|
{
|
764
|
790
|
residencyStart = millis();
|
765
|
791
|
}
|
|
@@ -943,8 +969,6 @@ inline void process_commands()
|
943
|
969
|
#ifdef PIDTEMP
|
944
|
970
|
case 301: // M301
|
945
|
971
|
{
|
946
|
|
-
|
947
|
|
-
|
948
|
972
|
if(code_seen('P')) Kp = code_value();
|
949
|
973
|
if(code_seen('I')) Ki = code_value()*PID_dT;
|
950
|
974
|
if(code_seen('D')) Kd = code_value()/PID_dT;
|
|
@@ -989,6 +1013,18 @@ inline void process_commands()
|
989
|
1013
|
|
990
|
1014
|
}
|
991
|
1015
|
}
|
|
1016
|
+ else if(code_seen('T')) {
|
|
1017
|
+ tmp_extruder = code_value();
|
|
1018
|
+ if(tmp_extruder >= EXTRUDERS) {
|
|
1019
|
+ SERIAL_ECHO_START;
|
|
1020
|
+ SERIAL_ECHO("T");
|
|
1021
|
+ SERIAL_ECHO(tmp_extruder);
|
|
1022
|
+ SERIAL_ECHOLN("Invalid extruder");
|
|
1023
|
+ }
|
|
1024
|
+ else {
|
|
1025
|
+ active_extruder = tmp_extruder;
|
|
1026
|
+ }
|
|
1027
|
+ }
|
992
|
1028
|
else
|
993
|
1029
|
{
|
994
|
1030
|
SERIAL_ECHO_START;
|