Browse Source

Temperature updates for parity with 1.1.x

Scott Lahteine 7 years ago
parent
commit
5e01ee8adf
2 changed files with 126 additions and 112 deletions
  1. 82
    84
      Marlin/src/module/temperature.cpp
  2. 44
    28
      Marlin/src/module/temperature.h

+ 82
- 84
Marlin/src/module/temperature.cpp View File

244
       ;
244
       ;
245
       const int8_t watch_temp_period =
245
       const int8_t watch_temp_period =
246
         #if ENABLED(THERMAL_PROTECTION_BED) && ENABLED(PIDTEMPBED) && ENABLED(THERMAL_PROTECTION_HOTENDS) && ENABLED(PIDTEMP)
246
         #if ENABLED(THERMAL_PROTECTION_BED) && ENABLED(PIDTEMPBED) && ENABLED(THERMAL_PROTECTION_HOTENDS) && ENABLED(PIDTEMP)
247
-          hotend < 0 ? THERMAL_PROTECTION_BED_PERIOD : THERMAL_PROTECTION_PERIOD
247
+          hotend < 0 ? WATCH_BED_TEMP_PERIOD : WATCH_TEMP_PERIOD
248
         #elif ENABLED(THERMAL_PROTECTION_BED) && ENABLED(PIDTEMPBED)
248
         #elif ENABLED(THERMAL_PROTECTION_BED) && ENABLED(PIDTEMPBED)
249
-          THERMAL_PROTECTION_BED_PERIOD
249
+          WATCH_BED_TEMP_PERIOD
250
         #else
250
         #else
251
-          THERMAL_PROTECTION_PERIOD
251
+          WATCH_TEMP_PERIOD
252
         #endif
252
         #endif
253
       ;
253
       ;
254
       const int8_t watch_temp_increase =
254
       const int8_t watch_temp_increase =
437
             next_watch_temp = input + watch_temp_increase;
437
             next_watch_temp = input + watch_temp_increase;
438
             temp_change_ms = ms + watch_temp_period * 1000UL;
438
             temp_change_ms = ms + watch_temp_period * 1000UL;
439
           }
439
           }
440
-          else if ((!heated && ELAPSED(ms, temp_change_ms)) || (heated && input < temp - MAX_OVERSHOOT_PID_AUTOTUNE))
440
+          else if (!heated && ELAPSED(ms, temp_change_ms))
441
+            _temp_error(hotend, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
442
+          else if (heated && input < temp - MAX_OVERSHOOT_PID_AUTOTUNE)
441
             _temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY), PSTR(MSG_THERMAL_RUNAWAY));
443
             _temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY), PSTR(MSG_THERMAL_RUNAWAY));
442
         #endif
444
         #endif
443
       } // every 2 seconds
445
       } // every 2 seconds
834
     #endif
836
     #endif
835
 
837
 
836
     #if HEATER_IDLE_HANDLER
838
     #if HEATER_IDLE_HANDLER
837
-      if (bed_idle_timeout_exceeded)
838
-      {
839
+      if (bed_idle_timeout_exceeded) {
839
         soft_pwm_amount_bed = 0;
840
         soft_pwm_amount_bed = 0;
840
-
841
         #if DISABLED(PIDTEMPBED)
841
         #if DISABLED(PIDTEMPBED)
842
           WRITE_HEATER_BED(LOW);
842
           WRITE_HEATER_BED(LOW);
843
         #endif
843
         #endif
847
     {
847
     {
848
       #if ENABLED(PIDTEMPBED)
848
       #if ENABLED(PIDTEMPBED)
849
         soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
849
         soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
850
-
851
-      #elif ENABLED(BED_LIMIT_SWITCHING)
850
+      #else
852
         // Check if temperature is within the correct band
851
         // Check if temperature is within the correct band
853
         if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
852
         if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
854
-          if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
855
-            soft_pwm_amount_bed = 0;
856
-          else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
857
-            soft_pwm_amount_bed = MAX_BED_POWER >> 1;
858
-        }
859
-        else {
860
-          soft_pwm_amount_bed = 0;
861
-          WRITE_HEATER_BED(LOW);
862
-        }
863
-      #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
864
-        // Check if temperature is within the correct range
865
-        if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
866
-          soft_pwm_amount_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
853
+          #if ENABLED(BED_LIMIT_SWITCHING)
854
+            if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
855
+              soft_pwm_amount_bed = 0;
856
+            else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
857
+              soft_pwm_amount_bed = MAX_BED_POWER >> 1;
858
+          #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
859
+            soft_pwm_amount_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
860
+          #endif
867
         }
861
         }
868
         else {
862
         else {
869
           soft_pwm_amount_bed = 0;
863
           soft_pwm_amount_bed = 0;
878
 
872
 
879
 // Derived from RepRap FiveD extruder::getTemperature()
873
 // Derived from RepRap FiveD extruder::getTemperature()
880
 // For hot end temperature measurement.
874
 // For hot end temperature measurement.
881
-float Temperature::analog2temp(int raw, uint8_t e) {
875
+float Temperature::analog2temp(const int raw, const uint8_t e) {
882
   #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
876
   #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
883
     if (e > HOTENDS)
877
     if (e > HOTENDS)
884
   #else
878
   #else
919
   return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
913
   return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
920
 }
914
 }
921
 
915
 
922
-// Derived from RepRap FiveD extruder::getTemperature()
923
-// For bed temperature measurement.
924
-float Temperature::analog2tempBed(const int raw) {
925
-  #if ENABLED(BED_USES_THERMISTOR)
926
-    float celsius = 0;
927
-    byte i;
928
-
929
-    for (i = 1; i < BEDTEMPTABLE_LEN; i++) {
930
-      if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
931
-        celsius  = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
932
-                   (raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
933
-                   (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
934
-                   (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
935
-        break;
916
+#if HAS_TEMP_BED
917
+  // Derived from RepRap FiveD extruder::getTemperature()
918
+  // For bed temperature measurement.
919
+  float Temperature::analog2tempBed(const int raw) {
920
+    #if ENABLED(BED_USES_THERMISTOR)
921
+      float celsius = 0;
922
+      byte i;
923
+
924
+      for (i = 1; i < BEDTEMPTABLE_LEN; i++) {
925
+        if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
926
+          celsius  = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
927
+                     (raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
928
+                     (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
929
+                     (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
930
+          break;
931
+        }
936
       }
932
       }
937
-    }
938
 
933
 
939
-    // Overflow: Set to last value in the table
940
-    if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
934
+      // Overflow: Set to last value in the table
935
+      if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
941
 
936
 
942
-    return celsius;
937
+      return celsius;
943
 
938
 
944
-  #elif defined(BED_USES_AD595)
939
+    #elif defined(BED_USES_AD595)
945
 
940
 
946
-    return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
941
+      return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
947
 
942
 
948
-  #else
943
+    #else
949
 
944
 
950
-    UNUSED(raw);
951
-    return 0;
945
+      UNUSED(raw);
946
+      return 0;
952
 
947
 
953
-  #endif
954
-}
948
+    #endif
949
+  }
950
+#endif // HAS_TEMP_BED
955
 
951
 
956
 /**
952
 /**
957
  * Get the raw values into the actual temperatures.
953
  * Get the raw values into the actual temperatures.
1236
     #endif // HOTENDS > 2
1232
     #endif // HOTENDS > 2
1237
   #endif // HOTENDS > 1
1233
   #endif // HOTENDS > 1
1238
 
1234
 
1239
-  #ifdef BED_MINTEMP
1240
-    while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
1241
-      #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
1242
-        bed_minttemp_raw += OVERSAMPLENR;
1243
-      #else
1244
-        bed_minttemp_raw -= OVERSAMPLENR;
1245
-      #endif
1246
-    }
1247
-  #endif // BED_MINTEMP
1248
-  #ifdef BED_MAXTEMP
1249
-    while (analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) {
1250
-      #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
1251
-        bed_maxttemp_raw -= OVERSAMPLENR;
1252
-      #else
1253
-        bed_maxttemp_raw += OVERSAMPLENR;
1254
-      #endif
1255
-    }
1256
-  #endif // BED_MAXTEMP
1235
+  #if HAS_TEMP_BED
1236
+    #ifdef BED_MINTEMP
1237
+      while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
1238
+        #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
1239
+          bed_minttemp_raw += OVERSAMPLENR;
1240
+        #else
1241
+          bed_minttemp_raw -= OVERSAMPLENR;
1242
+        #endif
1243
+      }
1244
+    #endif // BED_MINTEMP
1245
+    #ifdef BED_MAXTEMP
1246
+      while (analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) {
1247
+        #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
1248
+          bed_maxttemp_raw -= OVERSAMPLENR;
1249
+        #else
1250
+          bed_maxttemp_raw += OVERSAMPLENR;
1251
+        #endif
1252
+      }
1253
+    #endif // BED_MAXTEMP
1254
+  #endif // HAS_TEMP_BED
1257
 
1255
 
1258
   #if ENABLED(PROBING_HEATERS_OFF)
1256
   #if ENABLED(PROBING_HEATERS_OFF)
1259
     paused = false;
1257
     paused = false;
1348
     millis_t Temperature::thermal_runaway_bed_timer;
1346
     millis_t Temperature::thermal_runaway_bed_timer;
1349
   #endif
1347
   #endif
1350
 
1348
 
1351
-  void Temperature::thermal_runaway_protection(Temperature::TRState * const state, millis_t * const timer, const float current, const float target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
1349
+  void Temperature::thermal_runaway_protection(Temperature::TRState * const state, millis_t * const timer, const float &current, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
1352
 
1350
 
1353
     static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
1351
     static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
1354
 
1352
 
1371
 
1369
 
1372
     #if HEATER_IDLE_HANDLER
1370
     #if HEATER_IDLE_HANDLER
1373
       // If the heater idle timeout expires, restart
1371
       // If the heater idle timeout expires, restart
1374
-      if (heater_id >= 0 && heater_idle_timeout_exceeded[heater_id]) {
1372
+      if ((heater_id >= 0 && heater_idle_timeout_exceeded[heater_id])
1373
+        #if HAS_TEMP_BED
1374
+          || (heater_id < 0 && bed_idle_timeout_exceeded)
1375
+        #endif
1376
+      ) {
1375
         *state = TRInactive;
1377
         *state = TRInactive;
1376
         tr_target_temperature[heater_index] = 0;
1378
         tr_target_temperature[heater_index] = 0;
1377
       }
1379
       }
1378
-      #if HAS_TEMP_BED
1379
-        else if (heater_id < 0 && bed_idle_timeout_exceeded) {
1380
-          *state = TRInactive;
1381
-          tr_target_temperature[heater_index] = 0;
1382
-        }
1383
-      #endif
1384
       else
1380
       else
1385
     #endif
1381
     #endif
1386
-    // If the target temperature changes, restart
1387
-    if (tr_target_temperature[heater_index] != target) {
1388
-      tr_target_temperature[heater_index] = target;
1389
-      *state = target > 0 ? TRFirstHeating : TRInactive;
1382
+    {
1383
+      // If the target temperature changes, restart
1384
+      if (tr_target_temperature[heater_index] != target) {
1385
+        tr_target_temperature[heater_index] = target;
1386
+        *state = target > 0 ? TRFirstHeating : TRInactive;
1387
+      }
1390
     }
1388
     }
1391
 
1389
 
1392
     switch (*state) {
1390
     switch (*state) {
2172
       );
2170
       );
2173
     #endif
2171
     #endif
2174
     #if HAS_TEMP_BED
2172
     #if HAS_TEMP_BED
2175
-      print_heater_state(degBed(), degTargetBed(),
2173
+      print_heater_state(degBed(), degTargetBed()
2176
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2174
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2177
-          rawBedTemp(),
2175
+          , rawBedTemp()
2178
         #endif
2176
         #endif
2179
-        -1 // BED
2177
+        , -1 // BED
2180
       );
2178
       );
2181
     #endif
2179
     #endif
2182
     #if HOTENDS > 1
2180
     #if HOTENDS > 1
2183
-      HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e),
2181
+      HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e)
2184
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2182
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2185
-          rawHotendTemp(e),
2183
+          , rawHotendTemp(e)
2186
         #endif
2184
         #endif
2187
-        e
2185
+        , e
2188
       );
2186
       );
2189
     #endif
2187
     #endif
2190
     SERIAL_PROTOCOLPGM(" @:");
2188
     SERIAL_PROTOCOLPGM(" @:");

+ 44
- 28
Marlin/src/module/temperature.h View File

170
     #if ENABLED(PREVENT_COLD_EXTRUSION)
170
     #if ENABLED(PREVENT_COLD_EXTRUSION)
171
       static bool allow_cold_extrude;
171
       static bool allow_cold_extrude;
172
       static int16_t extrude_min_temp;
172
       static int16_t extrude_min_temp;
173
-      static bool tooColdToExtrude(uint8_t e) {
173
+      FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp; }
174
+      FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) {
174
         #if HOTENDS == 1
175
         #if HOTENDS == 1
175
           UNUSED(e);
176
           UNUSED(e);
176
         #endif
177
         #endif
177
-        return allow_cold_extrude ? false : degHotend(HOTEND_INDEX) < extrude_min_temp;
178
+        return tooCold(degHotend(HOTEND_INDEX));
179
+      }
180
+      FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) {
181
+        #if HOTENDS == 1
182
+          UNUSED(e);
183
+        #endif
184
+        return tooCold(degTargetHotend(HOTEND_INDEX));
178
       }
185
       }
179
     #else
186
     #else
180
-      static bool tooColdToExtrude(uint8_t e) { UNUSED(e); return false; }
187
+      FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
188
+      FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
181
     #endif
189
     #endif
182
 
190
 
183
   private:
191
   private:
285
     /**
293
     /**
286
      * Static (class) methods
294
      * Static (class) methods
287
      */
295
      */
288
-    static float analog2temp(int raw, uint8_t e);
289
-    static float analog2tempBed(int raw);
296
+    static float analog2temp(const int raw, const uint8_t e);
297
+
298
+    #if HAS_TEMP_BED
299
+      static float analog2tempBed(const int raw);
300
+    #endif
290
 
301
 
291
     /**
302
     /**
292
      * Called from the Temperature ISR
303
      * Called from the Temperature ISR
302
      * Preheating hotends
313
      * Preheating hotends
303
      */
314
      */
304
     #ifdef MILLISECONDS_PREHEAT_TIME
315
     #ifdef MILLISECONDS_PREHEAT_TIME
305
-      static bool is_preheating(uint8_t e) {
316
+      static bool is_preheating(const uint8_t e) {
306
         #if HOTENDS == 1
317
         #if HOTENDS == 1
307
           UNUSED(e);
318
           UNUSED(e);
308
         #endif
319
         #endif
309
         return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
320
         return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
310
       }
321
       }
311
-      static void start_preheat_time(uint8_t e) {
322
+      static void start_preheat_time(const uint8_t e) {
312
         #if HOTENDS == 1
323
         #if HOTENDS == 1
313
           UNUSED(e);
324
           UNUSED(e);
314
         #endif
325
         #endif
315
         preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
326
         preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
316
       }
327
       }
317
-      static void reset_preheat_time(uint8_t e) {
328
+      static void reset_preheat_time(const uint8_t e) {
318
         #if HOTENDS == 1
329
         #if HOTENDS == 1
319
           UNUSED(e);
330
           UNUSED(e);
320
         #endif
331
         #endif
329
       static int8_t widthFil_to_size_ratio(); // Convert Filament Width (mm) to an extrusion ratio
340
       static int8_t widthFil_to_size_ratio(); // Convert Filament Width (mm) to an extrusion ratio
330
     #endif
341
     #endif
331
 
342
 
343
+
332
     //high level conversion routines, for use outside of temperature.cpp
344
     //high level conversion routines, for use outside of temperature.cpp
333
     //inline so that there is no performance decrease.
345
     //inline so that there is no performance decrease.
334
     //deg=degreeCelsius
346
     //deg=degreeCelsius
335
 
347
 
336
-    static float degHotend(uint8_t e) {
348
+    FORCE_INLINE static float degHotend(const uint8_t e) {
337
       #if HOTENDS == 1
349
       #if HOTENDS == 1
338
         UNUSED(e);
350
         UNUSED(e);
339
       #endif
351
       #endif
340
       return current_temperature[HOTEND_INDEX];
352
       return current_temperature[HOTEND_INDEX];
341
     }
353
     }
342
-    static float degBed() { return current_temperature_bed; }
354
+    FORCE_INLINE static float degBed() { return current_temperature_bed; }
343
 
355
 
344
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
356
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
345
-      static int16_t rawHotendTemp(uint8_t e) {
357
+      FORCE_INLINE static int16_t rawHotendTemp(const uint8_t e) {
346
         #if HOTENDS == 1
358
         #if HOTENDS == 1
347
           UNUSED(e);
359
           UNUSED(e);
348
         #endif
360
         #endif
349
         return current_temperature_raw[HOTEND_INDEX];
361
         return current_temperature_raw[HOTEND_INDEX];
350
       }
362
       }
351
-      static int16_t rawBedTemp() { return current_temperature_bed_raw; }
363
+      FORCE_INLINE static int16_t rawBedTemp() { return current_temperature_bed_raw; }
352
     #endif
364
     #endif
353
 
365
 
354
-    static int16_t degTargetHotend(uint8_t e) {
366
+    FORCE_INLINE static int16_t degTargetHotend(const uint8_t e) {
355
       #if HOTENDS == 1
367
       #if HOTENDS == 1
356
         UNUSED(e);
368
         UNUSED(e);
357
       #endif
369
       #endif
358
       return target_temperature[HOTEND_INDEX];
370
       return target_temperature[HOTEND_INDEX];
359
     }
371
     }
360
 
372
 
361
-    static int16_t degTargetBed() { return target_temperature_bed; }
373
+    FORCE_INLINE static int16_t degTargetBed() { return target_temperature_bed; }
362
 
374
 
363
     #if WATCH_HOTENDS
375
     #if WATCH_HOTENDS
364
       static void start_watching_heater(const uint8_t e = 0);
376
       static void start_watching_heater(const uint8_t e = 0);
399
       #endif
411
       #endif
400
     }
412
     }
401
 
413
 
402
-    static bool isHeatingHotend(uint8_t e) {
414
+    FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
403
       #if HOTENDS == 1
415
       #if HOTENDS == 1
404
         UNUSED(e);
416
         UNUSED(e);
405
       #endif
417
       #endif
406
       return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX];
418
       return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX];
407
     }
419
     }
408
-    static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
420
+    FORCE_INLINE static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
409
 
421
 
410
-    static bool isCoolingHotend(uint8_t e) {
422
+    FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
411
       #if HOTENDS == 1
423
       #if HOTENDS == 1
412
         UNUSED(e);
424
         UNUSED(e);
413
       #endif
425
       #endif
414
       return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX];
426
       return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX];
415
     }
427
     }
416
-    static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
428
+    FORCE_INLINE static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
429
+
430
+    FORCE_INLINE static bool wait_for_heating(const uint8_t e) {
431
+      return degTargetHotend(e) > TEMP_HYSTERESIS && abs(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
432
+    }
417
 
433
 
418
     /**
434
     /**
419
      * The software PWM power for a heater
435
      * The software PWM power for a heater
480
 
496
 
481
     #if ENABLED(PROBING_HEATERS_OFF)
497
     #if ENABLED(PROBING_HEATERS_OFF)
482
       static void pause(const bool p);
498
       static void pause(const bool p);
483
-      static bool is_paused() { return paused; }
499
+      FORCE_INLINE static bool is_paused() { return paused; }
484
     #endif
500
     #endif
485
 
501
 
486
     #if HEATER_IDLE_HANDLER
502
     #if HEATER_IDLE_HANDLER
487
-      static void start_heater_idle_timer(uint8_t e, millis_t timeout_ms) {
503
+
504
+      static void start_heater_idle_timer(const uint8_t e, const millis_t timeout_ms) {
488
         #if HOTENDS == 1
505
         #if HOTENDS == 1
489
           UNUSED(e);
506
           UNUSED(e);
490
         #endif
507
         #endif
492
         heater_idle_timeout_exceeded[HOTEND_INDEX] = false;
509
         heater_idle_timeout_exceeded[HOTEND_INDEX] = false;
493
       }
510
       }
494
 
511
 
495
-      static void reset_heater_idle_timer(uint8_t e) {
512
+      static void reset_heater_idle_timer(const uint8_t e) {
496
         #if HOTENDS == 1
513
         #if HOTENDS == 1
497
           UNUSED(e);
514
           UNUSED(e);
498
         #endif
515
         #endif
503
         #endif
520
         #endif
504
       }
521
       }
505
 
522
 
506
-      static bool is_heater_idle(uint8_t e) {
523
+      FORCE_INLINE static bool is_heater_idle(const uint8_t e) {
507
         #if HOTENDS == 1
524
         #if HOTENDS == 1
508
           UNUSED(e);
525
           UNUSED(e);
509
         #endif
526
         #endif
511
       }
528
       }
512
 
529
 
513
       #if HAS_TEMP_BED
530
       #if HAS_TEMP_BED
514
-        static void start_bed_idle_timer(millis_t timeout_ms) {
531
+        static void start_bed_idle_timer(const millis_t timeout_ms) {
515
           bed_idle_timeout_ms = millis() + timeout_ms;
532
           bed_idle_timeout_ms = millis() + timeout_ms;
516
           bed_idle_timeout_exceeded = false;
533
           bed_idle_timeout_exceeded = false;
517
         }
534
         }
524
           #endif
541
           #endif
525
         }
542
         }
526
 
543
 
527
-        static bool is_bed_idle() {
528
-          return bed_idle_timeout_exceeded;
529
-        }
544
+        FORCE_INLINE static bool is_bed_idle() { return bed_idle_timeout_exceeded; }
530
       #endif
545
       #endif
531
-    #endif
546
+
547
+    #endif // HEATER_IDLE_HANDLER
532
 
548
 
533
     #if HAS_TEMP_HOTEND || HAS_TEMP_BED
549
     #if HAS_TEMP_HOTEND || HAS_TEMP_BED
534
       static void print_heaterstates();
550
       static void print_heaterstates();
574
 
590
 
575
       typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
591
       typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
576
 
592
 
577
-      static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float current, const float target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
593
+      static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float &current, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
578
 
594
 
579
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
595
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
580
         static TRState thermal_runaway_state_machine[HOTENDS];
596
         static TRState thermal_runaway_state_machine[HOTENDS];

Loading…
Cancel
Save