Browse Source

Minor changes in the temperature code for some cleanup.

daid303 11 years ago
parent
commit
529748894c
1 changed files with 27 additions and 38 deletions
  1. 27
    38
      Marlin/temperature.cpp

+ 27
- 38
Marlin/temperature.cpp View File

@@ -111,33 +111,24 @@ static volatile bool temp_meas_ready = false;
111 111
   unsigned long watchmillis = 0;
112 112
 #endif //WATCHPERIOD
113 113
 
114
-// Init min and max temp with extreme values to prevent false errors during startup
115
-  static int minttemp[EXTRUDERS] = { 0 };
116
-  static int maxttemp[EXTRUDERS] = { 16383 }; // the first value used for all
117
-  static int bed_minttemp = 0;
118
-  static int bed_maxttemp = 16383;
119
-  static void *heater_ttbl_map[EXTRUDERS] = { (void *)heater_0_temptable
120
-#if EXTRUDERS > 1
121
-                                            , (void *)heater_1_temptable
122
-#endif
123
-#if EXTRUDERS > 2
124
-                                            , (void *)heater_2_temptable
125
-#endif
126
-#if EXTRUDERS > 3
127
-  #error Unsupported number of extruders
128
-#endif
129
-  };
130
-  static int heater_ttbllen_map[EXTRUDERS] = { heater_0_temptable_len
131
-#if EXTRUDERS > 1
132
-                                             , heater_1_temptable_len
133
-#endif
134
-#if EXTRUDERS > 2
135
-                                             , heater_2_temptable_len
136
-#endif
137 114
 #if EXTRUDERS > 3
138
-  #error Unsupported number of extruders
115
+# error Unsupported number of extruders
116
+#elif EXTRUDERS > 2
117
+# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
118
+#elif EXTRUDERS > 1
119
+# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
120
+#else
121
+# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
139 122
 #endif
140
-  };
123
+
124
+// Init min and max temp with extreme values to prevent false errors during startup
125
+static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0, 0, 0);
126
+static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(16383, 16383, 16383); // the first value used for all
127
+static int bed_minttemp = 0;
128
+static int bed_maxttemp = 16383;
129
+static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS((void *)heater_0_temptable, (void *)heater_1_temptable, (void *)heater_2_temptable);
130
+static int heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS(heater_0_temptable_len, heater_1_temptable_len, heater_2_temptable_len);
131
+
141 132
 
142 133
 //===========================================================================
143 134
 //=============================   functions      ============================
@@ -820,6 +811,9 @@ void max_temp_error(uint8_t e) {
820 811
     SERIAL_ERRORLN((int)e);
821 812
     SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
822 813
   }
814
+  #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
815
+  Stop();
816
+  #endif
823 817
 }
824 818
 
825 819
 void min_temp_error(uint8_t e) {
@@ -829,6 +823,9 @@ void min_temp_error(uint8_t e) {
829 823
     SERIAL_ERRORLN((int)e);
830 824
     SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
831 825
   }
826
+  #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
827
+  Stop();
828
+  #endif
832 829
 }
833 830
 
834 831
 void bed_max_temp_error(void) {
@@ -839,16 +836,19 @@ void bed_max_temp_error(void) {
839 836
     SERIAL_ERROR_START;
840 837
     SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
841 838
   }
839
+  #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
840
+  Stop();
841
+  #endif
842 842
 }
843 843
 
844
-#define HEAT_INTERVAL 250
845 844
 #ifdef HEATER_0_USES_MAX6675
845
+#define MAX6675_HEAT_INTERVAL 250
846 846
 long max6675_previous_millis = -HEAT_INTERVAL;
847 847
 int max6675_temp = 2000;
848 848
 
849 849
 int read_max6675()
850 850
 {
851
-  if (millis() - max6675_previous_millis < HEAT_INTERVAL) 
851
+  if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) 
852 852
     return max6675_temp;
853 853
   
854 854
   max6675_previous_millis = millis();
@@ -1077,20 +1077,10 @@ ISR(TIMER0_COMPB_vect)
1077 1077
        if(current_raw[e] >= maxttemp[e]) {
1078 1078
           target_raw[e] = 0;
1079 1079
           max_temp_error(e);
1080
-          #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
1081
-          {
1082
-            Stop();;
1083
-          }
1084
-          #endif
1085 1080
        }
1086 1081
        if(current_raw[e] <= minttemp[e]) {
1087 1082
           target_raw[e] = 0;
1088 1083
           min_temp_error(e);
1089
-          #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
1090
-          {
1091
-            Stop();
1092
-          }
1093
-          #endif
1094 1084
        }
1095 1085
     }
1096 1086
   
@@ -1098,7 +1088,6 @@ ISR(TIMER0_COMPB_vect)
1098 1088
     if(current_raw_bed >= bed_maxttemp) {
1099 1089
        target_raw_bed = 0;
1100 1090
        bed_max_temp_error();
1101
-       Stop();
1102 1091
     }
1103 1092
 #endif
1104 1093
   }

Loading…
Cancel
Save